TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: xiaxiang on March 31, 2011, 05:35:26 AM

Title: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: xiaxiang on March 31, 2011, 05:35:26 AM
Some matter bothered me. If I load one program,how can I list all the values of the Variables?
I kown the way of  "! mw"  ( if Variables "mw" exit).
Supposed that I have loaded a function aa:
Code: [Select]
(defun c:aa (/ a b c d)
...
)

I just want a function such as:
Code: [Select]
(defun c:bb ( aa/ )
...
)


Then
Code: [Select]
(load bb.lsp)

Return values of a,b,c and d.

Any suggestion?
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: pBe on March 31, 2011, 07:42:55 AM
try something like this


Code: [Select]
(defun
   c:var_val ()
  (mapcar
    '(lambda (x)
       (print (list (eval x) (vl-princ-to-string (eval (read x)))))
       )
    (vl-remove-if
      '(lambda (X)
         (or (wcmatch
               x
               "*-*,*_*,C:,AC*,PI,@@@@@@@@@@@*,INITSTRING,PAUSE"
               )
             (not
               (or (eq (type (eval (read x))) 'INT)
                   (eq (type (eval (read x))) 'REAL)
                   (eq (type (eval (read x))) 'LIST)
                   (eq (type (eval (read x))) 'STR)
                   )
               )
             )
         )
      (atoms-family 1)
      )
    )
  (princ)
  )

Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: Lee Mac on March 31, 2011, 08:25:35 AM
Certainly not conclusive, but maybe more succinct:

Code: [Select]
(defun c:var_val nil
  (mapcar
    (function
      (lambda ( x ) (print (list (read x) (eval (read x)))))
    )
    (vl-remove-if
      (function
        (lambda ( x )
          (or (wcmatch x ":*,AC*,PI,T,PAUSE,INITSTRING,AI_SYSVAR,VLAX-*,VLR-*")
              (member (type (eval (read x))) '(SUBR USUBR EXRXSUBR))
          )
        )
      )
      (atoms-family 1)
    )
  )
  (princ)
)
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: Kerry on March 31, 2011, 05:12:27 PM

xiaxiang,

If I understand correctly, you want to determine the value of variables that are declared local to a VLX function.
The VLX is compiled so you won't know the variable symbols.
The Variables are local to the function, so will only be in scope while the function is processing.
So short answer is NO, you cant write a function to determine the variable values.
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: dgorsman on March 31, 2011, 05:52:27 PM
Isn't the short answer "You don't need to." ? They are all nil, since they are localized to the function until its running  :-)
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: xiaxiang on March 31, 2011, 10:30:45 PM
Thank you all guys.
If I search the Physical memory using winhex, I can get  Variable name something like "MW" with luck. So I'm certain that "MW" is local to the function.
You said that they were all Nil,but when I use "!MW" I can get the value.
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: xiaxiang on April 01, 2011, 03:02:40 AM
Thanks for reply#1 by pBe and reply#2 by Lee.
I've used your code,and it worked.
I will post the values of the Variables I get as doing copy from command line.The name of attached file is Variables.txt.
But I think that there were more Variables than I've get.So I will post my vlx file(y.vlx) ,maybe as a Challenge.
Maybe you can use the code to do more than I can.
Thanks !
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: Kerry on April 01, 2011, 03:27:09 AM

xiaxiang
From your text file
What are the variables ?
In which function are they defined ?
What are their values ?
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: xiaxiang on April 01, 2011, 05:18:48 AM

xiaxiang
From your text file
What are the variables ?
In which function are they defined ?
What are their values ?
Sorry ,Kerry
The  text file is got from the command line which is returned from the code that Lee posted in reply#2.
 You should load y.vlx firstly.
I only know that "mw" ----License Code
                       "I"-------something  relevant to License
...
and many Empty strings.
I want to get more information about this vlx program for Special use.
Thanks.
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: Lee Mac on April 01, 2011, 07:37:31 AM
Xiaxiang,

Many users (including me) will be hesitant to run a compiled vlx file from an unknown source (and quite rightly so), since you can't be sure of what is lurking in the code.

Lee
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: Kerry on April 01, 2011, 07:39:33 AM

Particularly as it's reading/Writing the registry so much
Title: Re: Help! How can I get all the values of the Variables when vlx has been loaded?
Post by: dgorsman on April 01, 2011, 10:21:15 AM
I only know that "mw" ----License Code
                       "I"-------something  relevant to License
...
and many Empty strings.
I want to get more information about this vlx program for Special use.
Thanks.

Whoa, there - that looks like an attempt to bypass someones protection scheme.  If you don't know whats inside the VLX can't be yours.   :police: