Author Topic: Challenge: Get all system variables with values  (Read 13297 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #30 on: October 13, 2006, 11:50:59 AM »
Sorry.  :cry:
Forgot to run it last night.  I can run it over the weekend and see what I get when I come back on Monday.  I have '06 still, so I can run it on both, and see what they return.

Tim,
Looks like you need to change the way empty strings are output.
Code: [Select]
(DIMBLK . )  -----> (DIMBLK . "")I can run it on 2006 if you want to compare or maybe you have 6 still.
Alan,
 This is how the code looks
Code: [Select]
(write-line (vl-princ-to-string (cons Str (getvar Str))) Opened)I guess I can make it a little better, and see if getvar returned an empty string.  Maybe something like
Code: [Select]
(write-line
 (strcat
  "("
  Str
  (if (= (getvar Str) "")
   "\"\""
  (vl-princ-to-string (getvar Str))
  ")"
 )
 Opened
)
« Last Edit: October 13, 2006, 11:58:07 AM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #31 on: October 13, 2006, 01:13:43 PM »
You could try this: :-)
Code: [Select]
(print (cons Str (getvar Str)) Opened)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #32 on: October 13, 2006, 01:38:07 PM »
You could try this: :-)
Code: [Select]
(print (cons Str (getvar Str)) Opened)
Didn't like that.  Here is the error
Quote
Error--> bad argument type: stringp ("DATE" . 2.45402e+006)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #33 on: October 13, 2006, 01:50:02 PM »
Just tested this in ACAD2000 & worked fine :?
Code: [Select]
(defun c:test (/ str)
  (setq fn (open "C:\\abc.txt" "w"))
  (setq str "dimblk")
  (print (cons Str (getvar Str)) fn)
  (setq str "date")
  (print (cons Str (getvar Str)) fn)
  (setq str "osmode")
  (print (cons Str (getvar Str)) fn)
  (close fn)
  (startapp "notepad.exe" "C:\\abc.txt")
  (princ)
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #34 on: October 13, 2006, 01:57:23 PM »
I was just about to say I made a stupid mistake, and that you are correct and works beautifully.  :-)

What I did was leave the 'write-line' and just add a 'print' to it, so it looked like
Code: [Select]
(write-line (print (cons Str (getvar Str))) Opened)Once I coded it correctly it worked like a charm.

Two things in two days you have thought me now.  Take the next two days off.  Thanks Alan.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #35 on: October 13, 2006, 02:12:42 PM »
Thank you sir.
I may just do that, take the next 2 days off. :)
We'll continue to learn from each other, keep up the good work. 8-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Swamp Rat
  • Posts: 1458
Re: Challenge: Get all system variables with values
« Reply #36 on: October 15, 2006, 06:16:18 AM »
Just a remark: If you only try the alphabeth, then variables like *_TOOLPALETTEPATH won't be in the list.
Vault Professional 2018     +     AEC Collection

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #37 on: October 16, 2006, 11:16:12 AM »
Just a remark: If you only try the alphabeth, then variables like *_TOOLPALETTEPATH won't be in the list.
You are correct, and I didn't think of this, but this way does not seem to be the right way of doing it.  My system did have some messages when I got in this morning, so it might not have ran all weekend long, but still, there has to be a better way.  After running it returned these two files.  One for 06 (electrical) and one for 07 (vanilla).  The last line in each file was cause by me this morning, escaping out of the commands.

'06 last two lines
Code: [Select]
("XREFCTL" . 0)
+++ Error! Last string evaluated was XSZSMIE +++
'07 last two lines
Code: [Select]
("QCSTATE" . 0)
+++ Error! Last string evaluated was QZTMHBY +++

There has to be a better way.  I will continue to look.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #38 on: October 16, 2006, 11:37:19 AM »
Something like this?
Code: [Select]
(while (< (strlen str) 16)
  (if (not (vl-catch-all-error-p
             (setq rtnval (vl-catch-all-apply 'getvar (list str)))
           )
      )
    (print (cons str rtnval) fn)
  )
  (setq str (upstringletters str (strlen str)))
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #39 on: October 16, 2006, 11:41:35 AM »
This is how I did it over the weekend since I thought I could get more system variables.
Code: [Select]
(while (< (strlen Str) 50)
 (if (getVar Str)
  (print (cons Str (getvar Str)) Opened)
 )
 (setq Str (UpStringLetters Str (strLen Str)))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #40 on: October 16, 2006, 11:50:26 AM »
That doesn't trap any errors that might occur & you are using getvar twice, not sure what the time penalty is for that.

What lisp statement generated the ERROR?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17662
  • Have thousands of dwgs to process? Contact me.
Re: Challenge: Get all system variables with values
« Reply #41 on: October 16, 2006, 11:53:12 AM »
Question Tim -- <I'm trying to understand the cost / benefit ratio> What's the consequence if you have most, but not necessarily all of the system variables? Is it just a curiosity thing or is some absolute need fueling this?

For example, instead of the interrogation methods you've been employing you might use the information for the latest AutoCAD version from Autodesk (say Shaan Hurley's, or some para-site spin off) against any running version of AutoCAD (removing invalid members on the fly could be done relatively quickly). Might be shy the odd variable because of inadvertent (or deliberate) omission. What's the consequence?

Nosey me.
Engineering Technologist CAD Specialist Programmer Analyst
Design Drafting Document Control Automation.
cadanalyst@fastmail.com https://cadanalyst.slack.com http://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #42 on: October 16, 2006, 12:09:29 PM »
That doesn't trap any errors that might occur & you are using getvar twice, not sure what the time penalty is for that.

What lisp statement generated the ERROR?
There is no error when you use getvar with and invalid string, it just returns nil, so if it returns nil, skip it, and on to the next string.  The error was me this morning hitting escape, so that I can do my work.  :-)

Question Tim -- <I'm trying to understand the cost / benefit ratio> What's the consequence if you have most, but not necessarily all of the system variables? Is it just a curiosity thing or is some absolute need fueling this?
Just to know.  I like knowing what I'm using, and I know you can get list of system variables off the net, but I was wondering how one would get a full list.  I think I have been to the hyperpics site for a list.  Thought it would be a fun thing to try.   :wink:  Seems a little harder than I thought though, but still fun.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Challenge: Get all system variables with values
« Reply #43 on: October 16, 2006, 12:12:37 PM »
OH, OK.

Well your computer has nothing better to do while you're away. :-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: Challenge: Get all system variables with values
« Reply #44 on: October 16, 2006, 12:25:35 PM »
Well your computer has nothing better to do while you're away. :-)
That is what I thought, but it didn't get as far as I hoped it would, so I think I need another approach.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.