Author Topic: How to find global variable  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to find global variable
« on: January 05, 2007, 03:57:02 AM »
Hi Alls,
if I load global variable in my acad session,and I forgot how many and what her name ,is there a way to search or to find total number and name of global variable.
Code: [Select]
(setq p1 1)
(setq p2 2)
(setq p3 3)
(setq str "Adesu")
(setq bla ...)
(setq bli ...)
(setq blo ...)
(setq ble ...)
(setq blu ...)
etc....etc

(defun c:to_find_global_variable ()
  (setq bla "etc")
  bla
  bla
  bla
  (princ (strcat "\nHere your global variable"
"\nNo.1 is " 1?
"\nNo.2 is " 2?
"\nNo.3 is " 3?
"\nNo.4 is " 4?))
  (princ)
  )

Command: to_find_global_variable

"\nHere your global variable"
"No.1 is  p1"
"No.2 is  p2"
"No.3 is  p3"
"No.4 is  str"
etc...
etc...

VVA

  • Newt
  • Posts: 166
Re: How to find global variable
« Reply #1 on: January 05, 2007, 04:56:23 AM »
Somehow so
Code: [Select]
(setq p1 1)
(setq p2 2)
(setq p3 3)
(setq str "Adesu")
(setq bla "bla")
(setq bli "bli")


(defun c:TEST ( / lst)
   (setq lst (atoms-family 1))
   (foreach sym lst
     (if (and (wcmatch sym "P#,STR,BL*")
      (not (member (type(eval (read sym))) '(USUBR SUBR)))
      )
       (progn
         (princ (strcat "\nVariable " sym "="))
(princ (eval (read sym)))
       )))
   (gc)
   (princ)
)
It is better to use a unique pattern for variables
Code: [Select]
(setq Adesu_p1 1)
(setq Adesu_p2 2)
(setq Adesu_p3 3)
(setq Adesu_str "Adesu")
(setq Adesu_bla "bla")
(setq Adesu_bli "bli")


(defun c:TEST ( / lst)
   (setq lst (atoms-family 1))
   (foreach sym lst
     (if (and (wcmatch sym "ADESU_*")
      (not (member (type(eval (read sym))) '(USUBR SUBR)))
      )
       (progn
         (princ (strcat "\nVariable " sym "="))
(princ (eval (read sym)))
       )))
   (gc)
   (princ)
  )

« Last Edit: January 05, 2007, 05:20:56 AM by VVA »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: How to find global variable
« Reply #2 on: January 05, 2007, 10:12:53 AM »
You also might want to take a look at this. Written by our resident genius MP.  :kewl:

http://www.theswamp.org/index.php?topic=1445.msg18109#msg18109

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Patrick_35

  • Guest
Re: How to find global variable
« Reply #3 on: January 05, 2007, 11:30:38 AM »
Hi
Or this

@+

Adesu

  • Guest
Re: How to find global variable
« Reply #4 on: January 07, 2007, 06:58:46 PM »
Hi VVA,
it's great and what as I looking for,thanks for your help.

Somehow so
Code: [Select]
(setq p1 1)
(setq p2 2)
(setq p3 3)
(setq str "Adesu")
(setq bla "bla")
(setq bli "bli")


(defun c:TEST ( / lst)
   (setq lst (atoms-family 1))
   (foreach sym lst
     (if (and (wcmatch sym "P#,STR,BL*")
      (not (member (type(eval (read sym))) '(USUBR SUBR)))
      )
       (progn
         (princ (strcat "\nVariable " sym "="))
(princ (eval (read sym)))
       )))
   (gc)
   (princ)
)
It is better to use a unique pattern for variables
Code: [Select]
(setq Adesu_p1 1)
(setq Adesu_p2 2)
(setq Adesu_p3 3)
(setq Adesu_str "Adesu")
(setq Adesu_bla "bla")
(setq Adesu_bli "bli")


(defun c:TEST ( / lst)
   (setq lst (atoms-family 1))
   (foreach sym lst
     (if (and (wcmatch sym "ADESU_*")
      (not (member (type(eval (read sym))) '(USUBR SUBR)))
      )
       (progn
         (princ (strcat "\nVariable " sym "="))
(princ (eval (read sym)))
       )))
   (gc)
   (princ)
  )