Hi all,
I’m having a mental collapse\ blank today. I'm trying to write a lisp that toggles between two custom lisp/ functions.
just incase, the lisp is to be incorperated into a button...
Can somebody help?
Solved! Go to Solution.
Solved by stevor. Go to Solution.
Not sure what you mean,
but an easy coding method to toggle between
two anything is use one autolisp variable as a key,
containing either T or nil. Ex:
(if togvar1
(progn (do-one-thing ) (setq TogVar1 nil) )
(progn (do-other-thing ) (setq TogVar1 t ) )
)
And it could be simplified various ways, but memory and speed is cheap..
And for toggleing between two alternate functions, like Func1 and Func2:
(if TogVar1 ( Func1 ) ( Func2 ) ) ; alternate functions
(setq TogVar1 ( not TogVar1 ) ) ; the toggle of the key
And by using an integer instead of the logic data in the key's state variable,
it can be extended to 3 or more states, and their associated processes, or functions.
thanks this helped...
(defun C:TOGGEL () (if togvar1 (progn (TOMMY) (setq TogVar1 nil) ) (progn (TUCKER) (setq TogVar1 t ) ) ) ) (defun TOMMY () (alert "TOMMY!") ;Sets the next toggel command in place... (setq TogVar1 t ) ) (defun TUCKER () (alert "TUCKER!") ;Sets the next toggel command in place... (setq TogVar1 nil) )
ofcause this is just a test to the entier lisp.
Another option to avoid the global variable:
(defun c:toggle nil (tommy)) (defun tommy nil (alert "Tommy!") (defun c:toggle nil (tucker)) (princ) ) (defun tucker nil (alert "Tucker!") (defun c:toggle nil (tommy)) (princ) )
Can't find what you're looking for? Ask the community or share your knowledge.