Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Making my lisp (fas) version dependant...

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
The_Caddie
448 Views, 7 Replies

Making my lisp (fas) version dependant...

I would like to know how I can compare the value of a variable to a set string of text if the two prove to be equal perform task A if the two prove different perform task B?

7 REPLIES 7
Message 2 of 8
_Tharwat
in reply to: The_Caddie

Hi ,

 

Can you give an example of your variables and text's values ?

 

Maybe the function member is the one you looking for .

Message 3 of 8
The_Caddie
in reply to: The_Caddie

Well I want to compare the ACADVER variable with the text “18.2s (LMS Tech)” . then using the IF ELS method compare the tow values if the same go to IF, if different go to ELS. That’s the basic now I just want to know how / if at all its possible to compare and process the two values?

Message 4 of 8
_Tharwat
in reply to: The_Caddie

One way ....

(if (eq (getvar 'acadver) "18.2s (LMS Tech)")
  (princ "\n that's correct ")
  (princ "\n That's wrong ")
)

 Another ....

 

(if (wcmatch (getvar 'acadver) "18.2s (LMS Tech)")
  (princ "\n that's correct ")
  (princ "\n That's wrong ")
)

 

Message 5 of 8
The_Caddie
in reply to: _Tharwat

Whats the diffrence between the two methods?

Message 6 of 8
_Tharwat
in reply to: The_Caddie

Actualy nothing , but with function wcmatch you can check the string if it has a specific string within e.g.

 

(wcmatch  (getvar 'acadver) "18.*")

 

but with eq function , the strings must be equal ( the same )

Message 7 of 8
Kent1Cooper
in reply to: _Tharwat


@_Tharwat wrote:

One way ....

(if (eq (getvar 'acadver) "18.2s (LMS Tech)")....

.... 


You can also use the (=) function for that [it will compare either text strings or numerical values]:

 

(if (= (getvar 'acadver) "18.2s (LMS Tech)")....

Kent Cooper, AIA
Message 8 of 8
_Tharwat
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@_Tharwat wrote:

One way ....

(if (eq (getvar 'acadver) "18.2s (LMS Tech)")....

.... 


You can also use the (=) function for that [it will compare either text strings or numerical values]:

 

(if (= (getvar 'acadver) "18.2s (LMS Tech)")....


That's right ,

 

and you can also use member function for the same result . e,g .

 

(member (getvar 'acadver) '("18.2s (LMS Tech)")

 

Tharwat

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost