GETENV Value for Variable Not Changing Even When Variable Changes

GETENV Value for Variable Not Changing Even When Variable Changes

mgorecki
Collaborator Collaborator
882 Views
3 Replies
Message 1 of 4

GETENV Value for Variable Not Changing Even When Variable Changes

mgorecki
Collaborator
Collaborator

Hello,

I'm updating one of my programs to use a system environment variable to set a value in the program:

(setq CadenceVersion (substr (getenv "CDSROOT") 16 5)) 

This should get me either "16.6" or "17.2" depending on what the CDSROOT env var is set to.

 

The problem is that while testing, I run the command and it comes back with "17.2".  I edit the env vars and change CDSROOT to 16.6 and save it.  I try the same command in the LiSP editor again, but I still get "17.2".

 

I have to exit AutoCAD and re-launch, then reopen the autoLiSP editor and run the command again to get the "16.6" value.  If I change the CDSROOT value back to "17.2", it still tells me that it's "16.6" unless I quit and restart again.

 

Does anyone know of a better way to get the real value of env vars (real time).

 

Thanks,

Mark

0 Likes
Accepted solutions (1)
883 Views
3 Replies
Replies (3)
Message 2 of 4

dgorsman
Consultant
Consultant
Accepted solution

From memory, the (get/setenv ...) functions aren't live to the registry, and changes are only made once the application is closed.  Almost all of my registry work is done through the (vl-registry-read/write/etc. ...) functions as they are both live to the registry and aren't limited to a default location inside the AutoCAD profile settings.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 3 of 4

Ranjit_Singh
Advisor
Advisor

If it is a variable that the application creates (references for maintaining some other settings) then sometimes you are restricted from changing it unless the application quits. See this link with one example where the user had to quit application before making changes.

If it is a user created variable then, AFAIK, it should not be a problem. What is the source of your variable?getenv.gif

0 Likes
Message 4 of 4

mgorecki
Collaborator
Collaborator

Hi dgorsman,

Thanks for the information.  I'll try my hand at getting registry values.

 

Best regards,

Mark

0 Likes