Jump to content

Recommended Posts

Posted

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.

Posted

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
)

Posted

Simple example:

 

(defun c:test (/ num)

   (defun getnum ()
   (setq num (getreal "\nChoose a Number: "))
   ) ;_  end defun

   (getnum)

   (alert (rtos num))
   (princ)
) ;_  end defun

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...