setting environment variables
[1/3] from: scott:jaderholm at: 29-Aug-2002 17:01
Hi,
Is there a way in REBOL/Core to set an environment variable? I want to
set TZ so I can easily get the time and date of various places around
the world.
Sincerely,
Scott
[2/3] from: greggirwin:mindspring at: 29-Aug-2002 17:25
Hi Scott,
<< Is there a way in REBOL/Core to set an environment variable? I want to
set TZ so I can easily get the time and date of various places around
the world. >>
Not in Core. With Command or View/Pro, I just whacked this up.
lib: load/library %msvcrt.dll
get-env: make routine! [
varname [string!]
return: [string!]
] lib "getenv"
put-env: make routine! [
env-string [string!]
return: [integer!]
] lib "_putenv"
remove-env-var: func [name [string!]] [put-env join name "="]
tz-set: make routine! [
return: [integer!]
] lib "_tzset"
print get-env "path"
print get-env "lib"
print get-env "temp"
print get-env "test"
if 0 <> put-env "test=blah" [
print "error writing environment variable"
]
print get-env "test"
print get-env "TZ"
tz-set
free lib
halt
HTH!
--Gregg
[3/3] from: greggirwin::mindspring::com at: 29-Aug-2002 17:50
Scott,
I should note that this is a Windows solution, not cross platform.
--Gregg
Librarian comment
It is now possible to set an environment variable by calling a command line function. The call function is now available in REBOL/Core. It is documented at REBOL Command Shell Interface
Getting an environment variable is completely another matter.