In VSCode how do I find all the Global variables in a function

In VSCode how do I find all the Global variables in a function

jshimkus
Advocate Advocate
918 Views
4 Replies
Message 1 of 5

In VSCode how do I find all the Global variables in a function

jshimkus
Advocate
Advocate

I'm writing Lisp with VSCode and I need to find all the "Global" variables in a function so I can begin "Localizing" them.

This was pretty easy to do in VisualLisp, but how do I find the "Global" variables in VSCode? 

0 Likes
Accepted solutions (1)
919 Views
4 Replies
Replies (4)
Message 2 of 5

hak_vz
Advisor
Advisor

I don't use VSCODE for lisp programming so I don't know if there is a IDE function that would extract all function variables for code written in autolisp/visuallisp. Logic is that all variables that are not added to localizing section of function definition are global. Some variables are intentionally created as global so localizing them may crash the code. Instead of relying on IDE functionality, read your code and localize variables defined inside function definition.

Variable can be set in different ways so I don' know if editor is capable to trace all function definitions.

(setq a 1 b 2)
(mapcar 'set '(a b) '( 1 2)) 
(set 'a 1) (set 'b 2)
(set (read name) 1)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 5

jshimkus
Advocate
Advocate

Thanks, manually reading and localizing the variables is what I have been doing.

I was hoping that there was a trick, an extension or a json setting that would help point out the globals. 

0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor
Accepted solution

@jshimkus 

As long as there is an atoms-family function and VLisp functions...

Before your function call, (setq before (atoms-family 1))

After your function is called, (setq after (atoms-family 1))

Then, (setq global (vl-remove-if '(lambda (x)(vl-position x before)) after))

If you don't want the symbols as strings, leave out the 1.

John F. Uhden

0 Likes
Message 5 of 5

jshimkus
Advocate
Advocate

Thanks John, that will work for now.

0 Likes