Skip to main content

$ZMODE (ObjectScript)

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.):

    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" }

USER>DO ^zmodetest


S is not set


S is set

See Also

FeedbackOpens in a new tab