The %getenv() function searches the environment for a string of the form name=value and returns a pointer to value in the current environment if such a string is present, otherwise, a null is returned.
Syntax
pointer = (char*)%getenv(name) |
NOTE |
The pointer returned points to the environment space. It is not a static area and may change. |
Example(s)
* Gets and displays the PATH environment variable cfunction unix.builtin pointer=(char*)%getenv('PATH') if pointer = 0 then print "PATH is not defined" end else * We got a C pointer the path variable. Copy it * into pick variable char path[1024] %strcpy(path, (char*)pointer) path = field(path,char(0),1) print path end |
See Also