Author Topic: Get a list of global variables  (Read 3451 times)

0 Members and 1 Guest are viewing this topic.

AIberto

  • Guest
Get a list of global variables
« on: August 18, 2015, 07:10:51 AM »
Dear all

Before appload lisp (fas ,vlx ) , record global variables. (can use "atoms-family" func ?)
After appload lisp (fas, vlx) , record global variables. 
Than ,get a list of global variables. Is this possible?

I've done a little bit of searching for this, but have not found what I've needed.
but would like to know if anyone has come up with a lisp or other solution.


BTW
I see an article  "A Shortcut to Localising Variables" by Lee, http://www.lee-mac.com/quicklocalising.html
I feel vlide IDE is not reliable ,
A test .
Simple code
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ fun1 fun2 s1 s2 d g)
  2.         (defun fun1 (p / a b c)
  3.                 (setq a 10)
  4.                 (setq b 20)
  5.                 (setq c (+ a b))
  6.                 (setq d (* p c))
  7.                 d
  8.         );_end_defun_fun1
  9.         (defun fun2 (/ e f )
  10.                 (fun1 3)
  11.                 (setq e 2)
  12.                 (setq f 10)
  13.                 (setq g (* d (* e f)))
  14.                 g
  15.         );_end_defun_fun2
  16.         (fun2)
  17.         (setq s1 20)
  18.         (setq s2 (* s1 g))
  19.         s2
  20. );_end defun
  21.  
  22.  

use vlide check .
Code: [Select]
[CHECKING TEXT <Untitled-0> loading...]
.
; warning: local variable used as function: FUN2
; === Top statistic:
; Global variables: (D G)
; Function definition (with number of arguments): ((FUN2 . 0) (FUN1 . 1) (C:TEST . 0))
; Check done.

My doubt is why "D" and "G" is global variables ?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Get a list of global variables
« Reply #1 on: August 18, 2015, 09:19:01 AM »
My doubt is why "D" and "G" is global variables ?

Because they are referenced in fun1 & fun2, but not declared local to these functions, hence the IDE reports them as global in this respect.

AIberto

  • Guest
Re: Get a list of global variables
« Reply #2 on: August 18, 2015, 09:58:27 AM »
My doubt is why "D" and "G" is global variables ?

Because they are referenced in fun1 & fun2, but not declared local to these functions, hence the IDE reports them as global in this respect.

Yes, Lee,  IDE is not Perfect , is a way to get a list of global variables ?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Get a list of global variables
« Reply #3 on: August 18, 2015, 11:34:44 AM »

AIberto

  • Guest
Re: Get a list of global variables
« Reply #4 on: August 18, 2015, 12:05:50 PM »


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Get a list of global variables
« Reply #6 on: August 19, 2015, 06:32:15 AM »