Caché ObjectScript Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

Contains current I/O device OPEN parameters.
$ZMODE contains the parameters specified with the OPEN or USE command for the current device. The string returned contains the parameters used to open the current I/O device in canonical form. These parameter values are separated by backslash delimiters. Open parameters like "M" on TCP/IP IO are canonicalized to "PSTE". The "Y" and "K" parameter values are always placed last.
This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.
The following example uses $ZMODE to return the parameters of the current device:
  WRITE !,"The current OPEN modes are: ",$PIECE($ZMODE,"\")
  WRITE !,"The NLS collation is: ",$PIECE($ZMODE,"\",2)
  WRITE !,"The network encoding is: ",$PIECE($ZMODE,"\",4)
The following example sets parameters for the current device with the USE command. It checks the current parameters with $ZMODE before and after the USE command. To test whether a specific parameter was set, this example uses the $PIECE function with the backslash delimiter, and tests for a value using the Contains operator ([). (See Operators in Using Caché ObjectScript.):
    IF $PIECE($ZMODE,"\")["S" {
      WRITE !, "S is set"  }
    ELSE {WRITE !, "S is not set" }
  USE 0:("":"IS":$CHAR(13,10))
    IF $PIECE($ZMODE,"\")["S" {
      WRITE !, "S is set"  }
    ELSE {WRITE !, "S is not set" }
SAMPLES>DO ^zmodetest
S is not set
S is set
See Also