Home > Class Reference > ENSLIB namespace > %SYSTEM.Util

%SYSTEM.Util

abstract class %SYSTEM.Util extends %SYSTEM.Help

The %SYSTEM.Util class provides an interface for managing utility functions.

You can use it via the special $SYSTEM object:

You can call help to get a list of all entrypoints:

Do $SYSTEM.Util.Help()

Method Inventory (Including Private)

Methods (Including Private)

classmethod BinaryDirectory() as %String
Returns the location of the binaries directory, where executables, DLL's, shared libraries, scripts, etc are kept.
classmethod CheckSwitch(SwitchNumber As %Integer) as %Integer
Check if this job could be blocked by the specific switch represented by 'SwitchNumber'.
Returns 1 if the job could pass this check (not blocked), returns 0 if this job will be blocked.
For switch 10 and 11, if the job could not pass this test it also returns the PID of the job who set this switch in the '0,PID' format.
classmethod Collation(String As %String, flag As %Integer, len As %Integer) as %String
Performs collation conversion.

Parameters

String : An expression specifying a string or number to be converted to a specified collation type.

flag : An integer code used to specify the desired collation type. Valid values are 0 through 9.

len : Optional -- The truncation length in characters, specified as an integer. Truncation is performed on the collation-converted string. This option can only be used with flag values of 7, 8, or 9. A decimal len value is truncated to its integer part. A negative or nonnumeric len value is treated as 0.

Description

Collation applies the collation type specified in flag to string. The following flag values are supported:

0 - EXACT : Returns string unchanged. Does not convert NULLs. Corresponds to the Cache SQL %EXACT function.

1 - SPACE : Appends a blank to beginning of string.

2 - MVR : Returns its argument converted to the MultiValue collation sequence. It is used when a string contains both numeric and non-numeric characters. It divides the expression string into substrings, each substring containing either all numeric or all non-numeric characters. The numeric substrings are sorted in signed numeric order. The non-numeric substrings are sorted in case-sensitive ASCII collation sequence.

3 - PLUS : Converts numerics and numeric strings to canonical numbers. A nonnumeric string is returned as 0.

4 - MINUS : Converts numerics and numeric strings to canonical numbers and prepends a minus sign. A nonnumeric string is returned as 0.

5 - UPPER : Converts letters to uppercase. Corresponds to the Cache SQL %UPPER function.

6 - ALPHAUP : Removes leading, trailing, and embedded blanks. Removes all punctuation characters, except commas (,) and question marks (?). Converts letters to uppercase. Corresponds to the Cache SQL %ALPHAUP function.

7 - SQLUPPER : Removes trailing blanks. Converts letters to uppercase. Appends a blank to beginning of string. Corresponds to the Cache SQL %SQLUPPER function.

8 - SQLSTRING : Removes trailing blanks. Appends a blank to beginning of string. Corresponds to the Cache SQL %SQLSTRING function.

9 - STRING : Removes leading, trailing, and embedded blanks. Removes all punctuation characters, except commas (,). Converts letters to uppercase. Appends a blank to beginning of string. Corresponds to the Cache SQL %STRING function.

Several of these collation conversions append a blank to the string. This forces numerics and the empty string to be collated as strings.

Numerics are converted to canonical form: leading and trailing zeros are removed, as is a trailing decimal point. Multiple plus and minus signs are resolved; if the resulting sign is a plus sign, it is removed.

The MINUS collation type appends a minus sign to the supplied sign before canonical resolution. Thus the MINUS collation of a negative number is a positive number. PLUS and MINUS resolve mixed numeric strings (such as "7dwarves") by truncating the string at the first nonnumeric character. PLUS and MINUS resolve nonnumeric strings by assigning them a value of 0.

classmethod Compress(OriginalString As %String) as %String
Returns the compressed form of a given string.
A Cache compressed string is a ZLIB compressed data block (as defined in RFC 1950) with a Cache-proprietary wrapper. Use Decompress() to decompress it.
classmethod CoreCountForNoFreezeDBERR(newvalue As %Integer) as %Integer
Configures the collection of core files from <DATABASE> errors which would not otherwise freeze the system.

Parameters

newvalue: An optional parameter which specifies the number of core files to capture from this type of problem. Negative values are treated as zero. If omitted the value is not changed.

Returns: The current value, before applying the optional new value.

<DATABASE> errors which result in a system freeze generate core files based on the dumpstyle system parameter. These can be disabled by setting this to NONE. Generally the system will generate either a FULL or PARTIAL dump file in this situation. This parameter controls whether we also generate core files (for use in dignaosing the cause of the trouble) from <DATABASE> which do not freeze the system. This is implemented as a counter of the # of files to collect. If this is set to zero we do not collect any. The default value is 1.

classmethod CreateDecimalGUID() as %String
Creates and returns the decimal representation of a globally unique identifier.
A GUID is a 16 byte (128 bit) globally unique identifier.
classmethod CreateGUID() as %String
Creates and returns a globally unique identifier.
A GUID is a 16 byte (128 bit) globally unique identifier.
classmethod DatabaseLatency(Directory As %String = "") as %Integer
The class method call $SYSTEM.Util.DatabaseLatency(Directory) returns an integer value that describes the health of the mounted database residing in the specified directory. If the Directory argument is missing or is the empty string then the returned value describes health of the database that holds the data for the current default namespace.

If the specified directory does not exist or does not contain a mounted database then the <DIRECTORY> error is signaled.

If the directory does exist and the directory contains a mounted database then $SYSTEM.Util.DatabaseLatency(Directory) method will return an integer value representing the number milliseconds required to access block 1 of the database CACHE.DAT file.

NOTE: On many lightly loaded platforms a call on this method will often return 0, or maybe 1. On most systems there is high speed RAM memory built into the disc drive hardware in order to speed up disc operations. This is followed by some disk cache blocks in the system memory managed by the operating system. This is further followed by a database cache in the shared memory managed by the Caché kernel. The existence of these levels of cache memory means that reading block 1 of a CACHE.DAT file will often be done by copying data from one of these levels of cache memory rather than reading data from the spinning platters of the disk drive.

NOTE: Certain database files may not support this method. For example, calling $SYSTEM.Util.DatabaseLatency(Directory) specifying a database directory which is cluster mounted on a VMS system may signal the <DIRECTORY> error.

classmethod DecimalToHex(decimal As %String) as %String
Converts a decimal string to a hexadecimal string.
classmethod Decompress(CompressedString As %String) as %String
Returns the original form of a Cache compressed string (see Compress()).
classmethod GetEnviron(VariableName As %String) as %String
Returns the value of an environment variable.
classmethod GetFrameStackSize() as %Integer
Returns the configured frame stack size, in bytes.
This is the size that will be used for any new processes that are created.
classmethod GetOSVersionInfo() as %String
Returns MajorVersion.MinorVersion.BuildNumber on Windows.
Returns an unimplemented error on Unix or VMS.
classmethod GetPrio(pid As %Integer = "") as %Integer
Returns the priority of the current process or another process.
classmethod GetSessionId(arg As %Integer) as %Numeric
Returns the session Id on Windows.
If arg = 0 or no argument, returns the physical console Session Id or 0xffffffff if there is no session attached to the physical console. The physical console is the monitor, keyboard, and mouse.
If arg = 1, returns the session Id of the current process. On error, returns -GetLastError().
Returns an unimplemented error on Unix or VMS.
classmethod GetSwitch(SwitchNumber As %Integer) as