Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 1 of 8 (250 Views)
Accepted Solution

Making my lisp (fas) version dependant...

250 Views, 7 Replies
06-11-2012 12:12 AM

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?

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 ")
)

 


_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)")....


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

Distinguished Mentor
_Tharwat
Posts: 628
Registered: ‎07-02-2010
Message 2 of 8 (247 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 12:32 AM 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 .

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 3 of 8 (244 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 12:46 AM 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?

Distinguished Mentor
_Tharwat
Posts: 628
Registered: ‎07-02-2010
Message 4 of 8 (238 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 01:21 AM 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 ")
)

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 5 of 8 (235 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 01:28 AM in reply to: _Tharwat

Whats the diffrence between the two methods?

Distinguished Mentor
_Tharwat
Posts: 628
Registered: ‎07-02-2010
Message 6 of 8 (233 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 01:37 AM 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 )

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
Kent1Cooper
Posts: 5,779
Registered: ‎09-13-2004
Message 7 of 8 (213 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 05:17 AM 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
Distinguished Mentor
_Tharwat
Posts: 628
Registered: ‎07-02-2010
Message 8 of 8 (210 Views)

Re: Making my lisp (fas) version dependant...

06-11-2012 05:37 AM 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

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!