abstract class %SYSTEM.Util extends %SYSTEM.HelpThe %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:
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.
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.
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 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 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 SQL %ALPHAUP function.
7 - SQLUPPER : Removes trailing blanks. Converts letters to uppercase. Appends a blank to beginning of string. Corresponds to the SQL %SQLUPPER function.
8 - SQLSTRING : Removes trailing blanks. Appends a blank to beginning of string. Corresponds to the 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 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.
When Type is specified, it is the compress algorithm used to compress the data. Its value can be "zlib", "zstd" or "lz4". If Type is not specified then the "zlib" compression algorithm is used. A compressed string is a compressed data block with a customized wrapper. Use Decompress() to decompress it.
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.
A GUID is a 16 byte (128 bit) globally unique identifier.
version -- an optional argument specifying the protocol version used to generate an identifier.
Currently supports version 4 (random based) on all platforms and version 1 (mac based) on non-windows platforms.
All characters will be in lower-case if version number argument is passed in, according to the protocol standard.
Invoking CreateGUID() without specifying the version number returns a v1 GUID/UUID on non-windows platforms, and a v4 GUID/UUID on windows, with all characters in upper-case.
Return value -- a 128 bit GUID/UUID string.
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 the method will return a value representing the number of milliseconds required to access block 1 of the database file.
NOTE: On many lightly loaded platforms a call on this method will often return a very small value. On most systems there is high speed RAM memory built into the disk drive hardware in order to speed up disk operations. This is followed by some disk cache blocks in the system memory managed by the operating system. The existence of these levels of cache memory means that reading block 1 of a database 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, specifying a database directory which is cluster mounted may signal the <DIRECTORY> error.
This is the size that will be used for any new processes that are created.
Returns an unimplemented error on Unix or VMS.
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.
When the SwitchNumber is not specified, GetSwitch() returns one value containing the state of all system switches.
Each system switch is represented by a bit in this value, with switch 0 as the least significant bit and switch 31 as the most significant.
Switch 0 -> 1
Switch 1 -> 2
Switch 2 -> 4
Switch 31 -> 0x80000000
When the SwitchNumber is specified (0 to 31), GetSwitch() returns the state of the specific switch represented by SwitchNumber.
The return value is 1 if this switch is set, or 0 if it is cleared.
For switch 10 and 11, it also returns the PID of the job that set this switch in the '1,PID' format.
Switch Definitions -
Switches 0 to 7 are not used by the system and are reserved for the user.
Switch 8 (0x100) : Inhibits responding to network request for DCP, DDP and DTM. It does not block ECP traffic.
Switch 9 (0x200) : Inhibits new network signons, this only apply for DCP.
Switch 10(0x400) : Inhibits all global and lock access except by the job setting this switch.
Switch 11(0x800) : Inhibits all global and lock access except by the job setting this switch. This overrides switch 10 and is reserved for use by the system (should only be set by the system).
Switch 12(0x1000) : Inhibits new users/JOB commands to signon the system.
Switch 13(0x2000) : Inhibits sets, kills, and zsaves.
Switch 14(0x4000) : Inhibits access to globals and routines.
Switch 15(0x8000) : Allow network references from peers, even if switch 10,13, or 14 would normally prevent the access.
Switch 16(0x10000) : Used in ^SHUTDOWN only.
Switch 17(0x20000) : Used internally by system to skip waiting in journal synch.
Switch 18(0x40000) : Used internally by system to disable pausing processes in gblkrd() if the queue for a block gets too long.
Switch 19(0x80000) : Inhibits TSTART.
The return value reports whether the corresponding $HOROLOG time is adjusted by an additional DST hour.
Changes to $ZTIMEZONE will change the value of $HOROLOG but the time zone rules do not change. The time zone rules are always those used by the operating system on which the process is running. The time zone rules of the process will be applied to the local time.
The UTC time stamp is converted to a time_t value (taking into account
adjustments to $ztimezone) which is then used as input to call the C
Programming Language standard library routine localtime(). The
tm_isdst element of the returned tm struct is examined to determine if
the daylight savings time is in effect.
0 - DST is not in effect.
1 - DST is in effect.
-1 - It cannot be determined if DST is in effect.
This method returns the pathname of the Java executable, which can be used to build a command line on your system. The return value has been normalized, and is suitable for passing to $zf(-1) or $zf(-2).
The method uses the return value from the JavaHomeDirectory() method, appends the subdirectory "bin" to it, and then adds the Java executable name to the end. If the JavaHomeDirectory() method returns "", then it is assumed that the Java executable location is in the process path, and the return value of the method is simply the Java executable name.
This method does not test for the existence of the Java executable. It assumes it is located in the "bin" directory if JavaHomeDirectory() returns a non-null value, otherwise it must be in the path of the process executing the method.
s Status=$zf(-1,JavaExe_" -version")
This method returns the location of the Java Home directory on your system. The return value has been normalized, and is suitable for passing to $zf(-1) or $zf(-2).
The location of the Java Home directory which is returned is determined in the following order:
1) The directory location returned by the configuration parameter JavaHome in the cache.cpf file.
2) The directory location returned by the environment variable "JAVA_HOME".
3) If none of the above, a null string.
The priority of any jobbed process on the system = priority of parent + system job priority.
The new jobprio value is returned
Note: changing priority is almost never needed and can compromise system stability
h : A string representing Local time in the same format as that returned by $HOROLOG.
A string representing the corresponding UTC time in the same format as that returned by $ZTIMESTAMP.
Note: This method only supports dates between December 31, 1969 and January 18, 2038. Dates outside this range will give an <ILLEGAL VALUE> error.
Note: $ZTIMEZONE Warning
This method is unusual in that it adjusts the Local time by any changes made to the $ZTIMEZONE special variable. Use of the $ZTIMEZONE variable is limited to a few special situations. $ZTIMEZONE affects the value returned by $HOROLOG but most other date/time features and functions (including $ZDATETIME and $ZDATETIMEH) ignore $ZTIMEZONE changes. Even though changing $ZTIMEZONE will change the value returned by $HOROLOG, the time zone rules do not change. The time zone rules are always those used by the operating system on which the process is running. The $ZTIMEZONE special variable will probably become a legacy feature in future versions of the system. If possible, applications should avoid changing $ZTIMEZONE and should use $ZDATETIME(h,-3) to convert Local time to UTC time.
For more details see %SYSTEM.CPU.
String : An expression specifying a collated string to be converted back to POSSIBLE original value.
flag : An integer code used to specify the desired collation type. Valid value is 2.
RevCollation applies the collation type specified in flag to string. The
following flag values are supported:
2 - MVR : Returns its argument converted from 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. The result can differ from the original due to sign and leading zero suppression applied during the conversion to MVR collation.
The return value is a comma-delimited string with a value for each possible buffer size. The pieces correspond to buffer sizes 2K,4K,8K,16K,32K,64K.
If Arg is 0 or is omitted, the values are the amount of memory, in MegaBytes, allocated for each buffer size.
If Arg is 1, the values are the number of buffers allocated for each buffer size.
Processes that will access large portions of a database may be set into batch mode to limit their impact on other (non-batch mode) processes running on the system. In particular, batch mode processes are prevented from overwhelming the database cache with the database blocks that they read or modify.
flag : 1 sets batch mode; 0 clears batch mode
pid : (optional) target pid; if null or omitted target is the calling process
Returns the old value of the batch flag, or -1 if error
If size is 0, the system default size is set.
Returns the previous configured value.
The new priority is returned.
Note: changing process priority is almost never needed and can compromise system stability
When one parameter is specified, SetSwitch(SwitchValue)() sets the value of all system switches to SwitchValue.
It returns the original value of all switches.
This is not recommended to be used by users.
When two parameters are specified, SetSwitch(SwitchNumber,SwitchValue)() sets the value of the specific switch SwitchNumber to SwitchValue.
It returns the original switch value.
To set switch 10 or (11 in cluster), if the switch was set then the SetSwitch() won't do anything and the original value with the owner PID is returned in '1,PID' format..
To clear switch 10 or (11 in cluster), if the switch was cleared or was set by different process then the SetSwitch() won't do anything and the original value is returned.
See GetSwitch() for a definition of the switches.
TimeStamp : A string representing a UTC time in the same format as that returned by $ZTIMESTAMP.
A string representing the corresponding Local time in the same format as that returned by $HOROLOG.
Note: This method only supports dates between January 1, 1970 and January 18, 2038. Dates outside this range will give an <ILLEGAL VALUE> error.
Note: $ZTIMEZONE Warning
This function is unusual in that it adjusts the Local time by any changes made to the $ZTIMEZONE special variable. Use of the $ZTIMEZONE variable is limited to a few special situations. $ZTIMEZONE affects the value returned by $HOROLOG but most other date/time features and functions (including $ZDATETIME and $ZDATETIMEH) ignore $ZTIMEZONE changes. Even though changing $ZTIMEZONE will change the value of returned by $HOROLOG, the time zone rules do not change. The time zone rules are always those used by the operating system on which the process is running. The $ZTIMEZONE special variable will probably become a legacy feature in future versions of the system. If possible, applications should avoid changing $ZTIMEZONE and should use $ZDATETIMEH(timestamp,-3) to convert UTC time to Local time.
flag : 1 = stop if an error is found. Default is 0.
numbuf : For a big-endian system, specifies the number of buffers to allocate as a work area. Routines larger than this will not be checked. Default is 8. Little-endian systems do not allocate a work area.
The return value is a $LIST with at least one element.
The first element is the number of buffers (routines) that were checked.
If errors are found, there will be one list element for each error.
If numbuf is specified, there will be one element with the size of the largest routine found. If this value is larger than numbuf on a big-endian system then at least one routine was skipped.
Each error is itself a $LIST with these elements:
- The buffer number.
- The routine name.
- The error code.
- Additional information specific to the error code.
- The routine name.
Error code 1 is a crc error. The additional information is the expected crc value and the actual value.