Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

env variable not being set?

Status
Not open for further replies.

drdad5727

Programmer
Feb 28, 2005
28
0
0
US
Ok I made a teeny tiny little change :eek:) to the C-executable I use to launch my Tcl/Tk application and it stopped working. The problem seems to be that changes I make to the environment before I call Tk_Main/Tk_Init via code like this:

[tt]sprintf(tk, "TK_LIBRARY=%s\\tk", loaddir);
_putenv(tk);
free(tk);[/tt]

which has been working for over ten years, doesn't work, in the sense that the Tcl [tt]env[/tt] variable does not have a TK_LIBRARY entry. However, there is definitely a TK_LIBRARY entry in the environment, as I can tell by various means.

About all I did (-: was move the code that does those environment settings from a dll directly into the executable. If I did something else, I don't know what it is.

Any ideas why the [tt]env[/tt] variable isn't being populated?
 
It may have to do with the separation, that I think happened within the last 10 years, between "User" environment variables and "System" environment variables. I suspect you're changing the user-type env vars and you need to change the system type. You can check this out by going to the control panel, then system/advanced/environment variables. That said, I don't know how to make that happen in C.

_________________
Bob Rashkin
 
I thought I'd answer my own question.

I never did find out why it wasn't working, so I developed a workaround. I put all the values I wanted in the environment into the Tcl [tt]env[/tt] array by hand using code like this, before calling Tk_Init

Code:
for (i = 0; i < arrCt; i++) {
      char * value = getenv(setThese[i]);
     Tcl_SetVar2(interp, "env", setThese[i], value, TCL_GLOBAL_ONLY);
  }

I don't know why it didn't work, but it works now [sunshine]!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top