%getenv() function

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.


pointer = (char*)%getenv(name)
Note: The pointer returned points to the environment space. It is not a static area and may change.


* Gets and displays the PATH environment variable
cfunction unix.builtin
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