Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Variable Scope

20 REPLIES 20
Reply
Message 1 of 21
dbrblg
1359 Views, 20 Replies

Variable Scope

I've had a quick look around the forums but cannot find anything on variable scope......

 

How do I define a global variable where I can access from two different lisp functions?

 

For example, something along the lines of:

(vl-load-com)

[var x]

(defun func2 ()
  (setq x "ABC")
  (princ)
)

(defun func1 ()
  (setq x "DEF")
  (princ)
)

 

Thanks

 

 

20 REPLIES 20
Message 21 of 21
dbroad
in reply to: Moshe-A

Moshe,

This method I demonstrated is protected.  First, don't do something in a reactor than can be done otherwise.  If you use a reactor, the callbacks should be specifically named for use and should check that the event is applicable to them by qualifying by command name or otherwise, which the reactors do with the if function. Putting data in a non-reactor storage global is less protected than putting it in a reactor stored location.  I don't currently market my lisp applications but have in the past.

 

I cannot understand why you assume that this will cause problems.  Guess we'll leave as is with a difference of opinions. 

Architect, Registered NC, VA, SC, & GA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost