Author Topic: SETENV & GETENV as information storage?  (Read 4297 times)

0 Members and 1 Guest are viewing this topic.

ASMI

  • Guest
SETENV & GETENV as information storage?
« on: July 27, 2008, 11:19:12 AM »
I wish to take an interest at experts, why creation of own environment variables by function SETENV it is seldom used for session-to-session information storage? It would seem that can be easier than create environment variable with a unique name (programer think that unique :-)) and to read with the help GETENV? However many programers create keys in the Registry, work with *.ini-files or text files of the  own format. Whether there are for this purpose objective reasons?

Advantages are visible well, it is simplicity and high speed of reading from the Registry. What lacks?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
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

  • Water Moccasin
  • Posts: 1503
Re: SETENV & GETENV as information storage?
« Reply #2 on: July 27, 2008, 03:30:37 PM »
From the last link:
[...]The documentation warns that once you change the value of an environment variable with setenv, you should not count on getenv returning the correct value until the next time you start Autocad. [...]
Vault Professional 2023     +     AEC Collection

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: SETENV & GETENV as information storage?
« Reply #3 on: July 27, 2008, 10:49:16 PM »
I know the ARX docs do not mention any issues with these commands. I would say that you probably can rely on the data as long as you don’t try to edit the values in the registry manually, as the data is most likely cached by AutoCAD.

Personally I hate dumping to the registry and prefer to use an .INI or database.

 

ASMI

  • Guest
Re: SETENV & GETENV as information storage?
« Reply #4 on: July 28, 2008, 10:19:49 AM »
Thank you guys.

It approximately that that I thought to hear. I think that it simply unwillingness to keep the information in a place of the general using, but no more serious lacks are present.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SETENV & GETENV as information storage?
« Reply #5 on: July 28, 2008, 10:27:37 AM »
The implication here is that ACAD might cash the values of SETENV until ACAd is closed and
at that time write to the registry. If that is the case then any GETENV for values stored during
the current session may not reflect the correct values.
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.

ASMI

  • Guest
Re: SETENV & GETENV as information storage?
« Reply #6 on: July 28, 2008, 10:34:09 AM »
Quote
ACAD might cash the values of SETENV until ACAd is closed and
at that time write to the registry.

Ghosts?   :-o

Well, I and itself usually do in the Registry a separate branch. Simply wished to specify this question.

Thank you agan.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: SETENV & GETENV as information storage?
« Reply #7 on: July 28, 2008, 10:39:28 AM »
It seems that I was mistaken, Setenv is not cached but written directly to the registry.  :oops:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SETENV & GETENV as information storage?
« Reply #8 on: July 28, 2008, 10:45:12 AM »
From ACAD2k help
Quote
SETENV
Sets a system environment variable to a specified value
(setenv varname value)

Arguments

varname

A string specifying the name of the environment variable to be set. Environment variable names must be spelled and cased exactly as they are stored in the system registry.

value

A string specifying the value to set varname to.

Return Values

value

Examples

The following command sets the value of the MaxArray environment variable to 10000:

Command: (setenv "MaxArray" "10000")

"10000"

Note that changes to settings might not take effect until the next time AutoCAD is started.

SEE ALSO the getenv function.
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: SETENV & GETENV as information storage?
« Reply #9 on: July 28, 2008, 10:51:22 AM »
I just ran a little test with 09, and the data was updated immediately .. YMMV

ASMI

  • Guest
Re: SETENV & GETENV as information storage?
« Reply #10 on: July 28, 2008, 10:51:43 AM »
Quote
Note that changes to settings might not take effect until the next time AutoCAD is started.

Yes, but I think it for AutoCAD standard environment variable values, not for user values.  ???

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: SETENV & GETENV as information storage?
« Reply #11 on: July 28, 2008, 11:14:11 AM »
Quote
Note that changes to settings might not take effect until the next time AutoCAD is started.

Yes, but I think it for AutoCAD standard environment variable values, not for user values.  ???

Hmm, that could very well be, either way, there are many other options from XML to INI files, that have more predictable behavior. 
I prefer the zero impact methods

Chris

  • Swamp Rat
  • Posts: 548
Re: SETENV & GETENV as information storage?
« Reply #12 on: August 05, 2008, 08:10:17 AM »
From ACAD2k help
Quote
SETENV
Sets a system environment variable to a specified value
(setenv varname value)

Arguments

varname

A string specifying the name of the environment variable to be set. Environment variable names must be spelled and cased exactly as they are stored in the system registry.

value

A string specifying the value to set varname to.

Return Values

value

Examples

The following command sets the value of the MaxArray environment variable to 10000:

Command: (setenv "MaxArray" "10000")

"10000"

Note that changes to settings might not take effect until the next time AutoCAD is started.

SEE ALSO the getenv function.
the AutoCAD 2009 help pretty much says the same thing
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: SETENV & GETENV as information storage?
« Reply #13 on: August 05, 2008, 09:01:38 AM »
What’ s strange is that the ARX documents don’t say this for acedSetEnv, which lisp probably calls.