T2L Posted January 7, 2009 Posted January 7, 2009 I created (sample) a code like this and obviously is not working: can someone explain. (defun test1 (/ x) <----- declare variable x (setq x (.....)) <------- set variable ) (defun c:test2 () (test1) (setq x (.....)) <------- call variable again from test1 ) Also, can you post example (simple one...easy to comprehend) of how to pass argument back and forth between function. Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 You will need to localise the sub-function variable inside the main-function. i.e. (defun c:test2 (/ x) ; Better practice to put it here (defun test1 () <----- declare variable x (setq x (.....)) <------- set variable ) (test1) (setq x (.....)) <------- call variable again from test1 ) Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Simple example: (defun c:test (/ num) (defun getnum () (setq num (getreal "\nChoose a Number: ")) ) ;_ end defun (getnum) (alert (rtos num)) (princ) ) ;_ end defun Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.