Author Topic: Help! How can I get all the values of the Variables when vlx has been loaded?  (Read 3883 times)

0 Members and 1 Guest are viewing this topic.

xiaxiang

  • Guest
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?
« Last Edit: March 31, 2011, 05:41:55 AM by xiaxiang »

pBe

  • Bull Frog
  • Posts: 402
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)
  )

« Last Edit: March 31, 2011, 08:11:19 AM by pBe »

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
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)
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

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.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

dgorsman

  • Water Moccasin
  • Posts: 2437
Isn't the short answer "You don't need to." ? They are all nil, since they are localized to the function until its running  :-)
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

xiaxiang

  • Guest
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.

xiaxiang

  • Guest
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 !

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

xiaxiang
From your text file
What are the variables ?
In which function are they defined ?
What are their values ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

xiaxiang

  • Guest

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.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

Particularly as it's reading/Writing the registry so much
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

dgorsman

  • Water Moccasin
  • Posts: 2437
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:
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}