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?
Solved! Go to Solution.
Solved by _Tharwat. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by _Tharwat. Go to Solution.
Hi ,
Can you give an example of your variables and text's values ?
Maybe the function member is the one you looking for .
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?
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 ") )
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 )
@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