TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DanB on January 10, 2019, 01:34:50 PM
-
Looking for some guidance on how to make sure "aa" and "bb" are cleared once this is run. I've tried a few methods but not getting the desired results.
(defun c:test1 ()
(setq aa "This is test1...")
(mytest)
)
(defun c:test2 ()
(setq aa "This is test2...")
(mytest)
)
(defun mytest (aa / bb)
(setq bb 1)
(prompt aa)
(princ)
)
-
I would suggest the following:
(setq aa
"This is test1...") (mytest aa)
)
(setq aa
"This is test2...") (mytest aa)
)
(defun mytest
( aa
/ bb
) )
-
Thank You. In line#3 and #7 you've added "aa". Is this then referred to as the argument of "mytest". That's the portion I was missing during my testing.
edit - I was focused solely on the first line of the defun in my attempts.
-
Thank You. In line#3 and #7 you've added "aa". Is this then referred to as the argument of "mytest". That's the portion I was missing during my testing.
Exactly; in your code the variable 'aa' is global (i.e. residing in the document namespace) when defined within c:test1 and c:test2, whereas the parameter 'aa' required by your mytest function is local to the mytest function, and is assigned the value supplied when mytest is evaluated - in your code, you would have received a 'too few arguments' error.
In my code, the variable 'aa' is local to both c:test1 and c:test2 and the value of 'aa' is then passed to the function mytest and is assigned to the local parameter 'aa' in the mytest function.
-
Thanks again. And yes, the too few arguments error was what threw me off.