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 (247 Views)
Accepted Solution

Making my lisp (fas) version dependant...

247 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?

Distinguished Mentor
_Tharwat
Posts: 580
Registered: ‎07-02-2010
Message 2 of 8 (244 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 (241 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: 580
Registered: ‎07-02-2010
Message 4 of 8 (235 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 (232 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: 580
Registered: ‎07-02-2010
Message 6 of 8 (230 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,294
Registered: ‎09-13-2004
Message 7 of 8 (210 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: 580
Registered: ‎07-02-2010
Message 8 of 8 (207 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 .

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community