TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: laison on November 08, 2010, 10:21:29 PM
-
When writing code and you get to where you are going to set you OSMODE setting can you set more than 1 setting in the same line?
(setvar "osmode" 1, 2, 4, 32)
[CODE]
[/code]
-
You add them.
eg.
(setvar 'osmode (+ 1 2 4 32))
or (setvar 'osmode 39)
-
Given it's a bit coded integer I'd be more inclined to "or" the values together:
(setvar "osmode" (logior + 1 2 4 32))
I tried to rewrite this 3 times so I wouldn't sound like a dick without success; sorry, just sayin'.
shrug_icon_goes_here
-
No dick, just educating.
Thanks Michael.
I assume you meant: (logior 1 2 4 32)
-
yeah sh!t :lol: thanks for being gracious
I'll leave the error so the thread makes sense
-
logior makes more sense to me if you your trying to ensure that the new modes were added to the existing osmode setting.
(setq os (getvar "OSMODE"))
(setvar "OSMODE" (logior os 1 2 4 32))
It adds the bit regardless of the current setting.
I think I would stick with the plus just for readability. -David
-
So what does logior do?
dJE
-
...
I'll leave the error so the thread makes sense
heh, too bad some people dont share that basic courtesy.
-
Lets say you want to close a polyline : set the 1 bit in the group 70 flag
(setq flag (cdr (assoc 70 ed)))
Either of these statements work:
(if (/= (logand flag 1) 1)
(setq flag (+ flag 1)))
(logior flag 1)
Logior's advantage is that accepts multiple tests in a single call.
-David