$SYSTEM (ObjectScript)
Synopsis
$SYSTEM
$SY
$SYSTEM.class.method()
Description
$SYSTEM can be invoked as either a special variable or as a class which invokes methods that return system information.
$SYSTEM Special Variable
$SYSTEM as a special variable contains the local system name and the name of the current instance of InterSystems IRIS, separated by a colon (:). The name of the machine follows the case conventions of the local operating system and the name of the instance is in uppercase. For example:
MyComputer:IRISInstance
You can also determine your local system name using the LocalHostName()Opens in a new tab method:
WRITE $SYSTEM,!
WRITE $SYSTEM.INetInfo.LocalHostName()
The abbreviation $SY can only be used for $SYSTEM as a special variable.
$SYSTEM Class
$SYSTEM as a class provides access to a variety of system objects. You can invoke a method that returns information, or a method that performs some operation such as upgrading or loading and returns status information. InterSystems IRIS supports several classes of system objects, including the following:
-
Version: for version numbers of InterSystems IRIS and its components
-
SYS: for the system itself
-
OBJ: for Objects
-
SQL: for SQL queries
Note that object class names and method names are case-sensitive. Specifying the wrong case for these names results in a <CLASS DOES NOT EXIST> or <METHOD DOES NOT EXIST> error. If you do not specify parentheses with the method name, it issues a <SYNTAX> error.
$SYSTEM methods and properties can be accessed using dot syntax, as shown in the following equivalent syntax examples:
-
WRITE ##class(%SYSTEM.INetInfo).LocalHostName()
-
WRITE $SYSTEM.INetInfo.LocalHostName()
$SYSTEM can access the System API classes in the %SYSTEM class package, described in the InterSystems Class Reference documentation. Note that in the ##class syntax the %SYSTEM class package name is case-sensitive. In the $SYSTEM syntax the $SYSTEM keyword is not case-sensitive. For further information on using dot syntax, see Working with Registered Objects.
For further information on using %SYSTEM.OBJOpens in a new tab, refer to Flags and Qualifiers.
Examples
The following is an example of using $SYSTEM to invoke a method that displays a list of the classes available in the current namespace:
DO $SYSTEM.OBJ.ShowClasses()
This displays results like the following:
%SYS>d $system.OBJ.ShowClasses()
%SYS.APIManagement
%SYS.Audit
%SYS.AuditString
%SYS.ClusterInfo
%SYS.DatabaseQuery
...
SYS.WSMon.wsProcess
SYS.WSMon.wsResource
SYS.WSMon.wsSystem
You can list all of the methods for the OBJ class as follows. (By changing the class name, you can use this method to get a list for any system class):
DO $SYSTEM.OBJ.Help()
To list information about just one method in a class, specify the method name in the Help argument list, as shown in the following example:
DO $SYSTEM.OBJ.Help("Load")
The following are a few more examples of $SYSTEM that invoke methods:
DO $SYSTEM.OBJ.Upgrade()
WRITE !,"* * * * * * * * * * * "
DO $SYSTEM.CSP.DisplayConfig()
WRITE !,"* * * * * * * * * * * "
WRITE !,$SYSTEM.Version.GetPlatform()
WRITE !,"* * * * * * * * * * * "
WRITE !,$SYSTEM.SYS.TimeStamp()
The following example calls the same methods as the previous example, using the ##class(%SYSTEM) syntax form:
DO ##class(%SYSTEM.OBJ).Upgrade()
DO ##class(%SYSTEM.CSP).DisplayConfig()
WRITE !,##class(%SYSTEM.Version).GetPlatform()
WRITE !,##class(%SYSTEM.SYS).TimeStamp()
The previous two examples requires that UnknownUser have assigned the %DB_IRISSYS role.