getEnvironmentVariable: Difference between revisions
m (Conversion script moved page GetEnvironmentVariable to getEnvironmentVariable: Converting page titles to lowercase) |
m (Text replacement - "source>" to "syntaxhighlight>") |
||
Line 14: | Line 14: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
getEnvironmentVariable(varname) | getEnvironmentVariable(varname) | ||
</ | </syntaxhighlight> | ||
The value of {{code|varname}} specifies which environment variable is queried. On most operating systems, environment variables are all uppercase letters, but this is a naming convention and not required. Note that no way exists to query what all of the environment variables are, so the script writer must know which variable they want to retrieve. | The value of {{code|varname}} specifies which environment variable is queried. On most operating systems, environment variables are all uppercase letters, but this is a naming convention and not required. Note that no way exists to query what all of the environment variables are, so the script writer must know which variable they want to retrieve. | ||
Line 24: | Line 24: | ||
[getEnvironmentVariable("TEMP")] | [getEnvironmentVariable("TEMP")] | ||
[getEnvironmentVariable("USERNAME")] | [getEnvironmentVariable("USERNAME")] | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
[[Category:Miscellaneous Function]] | [[Category:Miscellaneous Function]] |
Revision as of 17:06, 14 March 2023
getEnvironmentVariable() Function
Note: This function can only be used in a Trusted Macro
This function is useful for situations where the script may wish to interact with the environment outside of MapTool, such as using the exportData() function to write a string to an external file.
Caution:
This function is considered experimental and its implementation and parameters may change.
Usage
<source lang="mtmacro" line> getEnvironmentVariable(varname) </syntaxhighlight>
The value of varname
specifies which environment variable is queried. On most operating systems, environment variables are all uppercase letters, but this is a naming convention and not required. Note that no way exists to query what all of the environment variables are, so the script writer must know which variable they want to retrieve.
Example
<source lang="mtmacro" line> [getEnvironmentVariable("PATH")] [getEnvironmentVariable("TEMP")] [getEnvironmentVariable("USERNAME")]
</syntaxhighlight>