OScript API/Built-in Package Index

Class: Env

The Env package provides a small set of services for reading and manipulating system environment variables.

Class Attributes

All locale-specific behavior (all categories).

Behavior of strcoll and strxfrm functions.

Behavior of character-handling functions (except isdigit, isxdigit, mbstowcs, and mbtowc, which are unaffected).

(Unix only) Behavior of messaging functions such as dgettext, gettext, and gettxt.

Monetary formatting information returned by the localeconv function.

Decimal-point character for formatted output routines (for example, printf), data conversion routines, and nonmonetary formatting information returned by localeconv function.

Behavior of strftime function.

Class Methods

Get( String environmentVariableName )

Returns the value of the specified environment variable.

GetDefault( String environmentVariableName, String defaultValue )

Returns the value of the specified environment variable if it exists; otherwise, it returns the specified default value.

Put( )

(UNIX only) Returns a Boolean indicating success in setting the specified environment variable.

SetLocale( Integer lcConstant, String lcString )

Returns the specified String, substituting environment variable values for "$"-prefixed names where indicated.

Translate( String translationString )

Class Attributes

Integer LC_ALL

All locale-specific behavior (all categories).

Integer LC_COLLATE

Behavior of strcoll and strxfrm functions.

Integer LC_CTYPE

Behavior of character-handling functions (except isdigit, isxdigit, mbstowcs, and mbtowc, which are unaffected).

Integer LC_MESSAGES

(Unix only) Behavior of messaging functions such as dgettext, gettext, and gettxt.

Integer LC_MONETARY

Monetary formatting information returned by the localeconv function.

Integer LC_NUMERIC

Decimal-point character for formatted output routines (for example, printf), data conversion routines, and nonmonetary formatting information returned by localeconv function.

Integer LC_TIME

Behavior of strftime function.

Class Methods

Get

String Get( String environmentVariableName )

Returns the value of the specified environment variable.

Parameters

environmentVariableName

An environment variable name.

Returns:

The value of the specified environment variable.

GetDefault

String GetDefault( String environmentVariableName,
                   String defaultValue )

Returns the value of the specified environment variable if it exists; otherwise, it returns the specified default value.

Parameters

environmentVariableName

An environment variable name.

defaultValue

A default value.

Returns:

The specified environment variable if it exists; otherwise, the specified default value.

Put

Boolean Put()

(UNIX only) Returns a Boolean indicating success in setting the specified environment variable. The nameValue argument has the format "environmentVariableName=value".

Returns:

Boolean indicating success in setting the specified environment variable.

Example

if ( Env.Put( "OTHOME=/usr/local/livelink" ) )

    Echo( "Put() success!" )
else
    Echo( "Put() failure." )
end

SetLocale

String SetLocale( Integer lcConstant,
                  String lcString )

Internal use only. Tests string behavior for other language locales.

Parameters

lcConstant

One of the category constants in LC_XXX.

lcString

A valid locale string.

Returns:

The string.

Translate

String Translate( String translationString )

Returns an evaluated translationString, substituting "$"-prefixed environment variable name(s) with corresponding environment variable value(s). Translate() resolves the environment variables in translationString as a typical UNIX shell would.

Parameters

translationString

A String to translate.

Returns:

The specified String with environment variable values substituted where indicated.

Example

Here is an example:

Echo( Env.Translate( "OTHOME=$OTHOME, and PATH=$PATH" ) )

 Copyright © 2023 OpenText Corporation. All rights reserved.