Env$() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312
Purpose

Get an Environment variable used by Windows operating system.

Syntax
Env$(environmentvar)

Where environmentvar is a string representing a system environment variable such as Path, LOCALAPPDATA, etc.

To see a list of environment variables available for use, open a DOS command prompt and type 'Set' and hit <Enter>.

Return Value

String

Description

Get an operating system environament variable such as System TEMP folder, PATH, USERNAME, APPDATA, etc.

Examples

Print Env$("TEMP")

Output should be like 'C:\Temp' or 'C:\Windows\Temp'.

Print Env$(SystemRoot)
Output would typically be 'C:\Windows'

Error Conditions

  • If an empty string or non-string parameter is passed to function an error will be thrown.

  • If a non-existent variable name (e.g.: "FooBar") is passed to function an empty string will be returned.

  • This is basically querying for a name that is not set, so an empty string will be returned.