# %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.

## 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(&#39;PATH&#39;)
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

- [%putenv() function](https://d3codex.com/pickbasic-flashbasic/percent-putenv-function/)
- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)
- [cfunction statement](https://d3codex.com/pickbasic-flashbasic/cfunction-statement/)
- [env command](https://d3codex.com/unix/env-command/)
- [environ command](https://d3codex.com/tcl/environ-command/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-getenv-function/ - part of the D3Codex reference.
