InterSystems IRIS Data Platform 2019.2  /  ObjectScript Reference

ObjectScript Reference
Previous section           Next section
InterSystems: The power behind what matters   

Contains status information for the current I/O device.
$ZB contains status information specific to the current I/O device following a READ operation.
This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.
$ZB and $KEY can both be used to return the READ termination character when reading from a character-based device or file. For character-based reads, these two special variables are very similar, but not identical. For block-based reads and writes use $ZB; $KEY does not provide support for block-based read and write operations. See $KEY for further details.
End-of-File Behavior
By default, InterSystems IRIS handles an end-of-file on a sequential file by issuing an <ENDOFFILE> error; it does not set $ZB. You can configure $ZB end-of-file behavior so that when an end-of-file is encountered, InterSystems IRIS does not issue an error, but sets $ZB to "" (the null string), and sets $ZEOF to -1.
To configure end-of-file handling, go to the Management Portal, select System Administration, Configuration, Additional Settings, Compatibility. View and edit the current setting of SetZEOF. When set to “true”, InterSystems IRIS sets $ZB to "" (the null string), and sets $ZEOF to -1. The default is “false”.
You can control end-of-file handling for the current process using the SetZEOF() method of the %SYSTEM.Process class. The system-wide default behavior can be established by setting the SetZEOF property of the Config.Miscellaneous class.
Reading from a Terminal or File
$ZB contains the terminating character (or character sequence) from a read operation involving a terminal, sequential file, or other character-based I/O device. $ZB can contain any of the following:
For example, consider the following variable-length read with a five-second timeout:
  READ !,"Enter number:",num:5
  WRITE !, num
If the user types 123 at the READ prompt and presses <RETURN>, InterSystems IRIS stores 123 in the num variable and stores <RETURN> (ASCII decimal code 13, hexadecimal 0D) in $ZB. If the READ times out, $ZB contains the null string; $ASCII("") returns a value of –1.
$ZB on the Command Line
When issuing commands interactively from the Terminal command line, you press <RETURN> to issue each command line. The $ZB and $KEY special variables record this command line terminator character. Therefore, when using $ZB or $KEY to return the termination status of a read operation, you must set a variable as part of the same command line.
For example, if you issue the command:
>READ x:10
from the command line, then check $ZB it will not contain the results of the read operation; it will contain the <RETURN> character that executed the command line. To return the results of the read operation, set a local variable with $ZB in the same command line, as follows:
>READ x:10 SET rzb=$ZB
This preserves the value of $ZB set by the read operation. To display this read operation value, issue either of the following command line statements:
   ; returns -1 for null string (time out), 
   ; returns ASCII decimal value for terminator character
>ZZDUMP rkey
   ; returns blank line for null string (time out)
   ; returns hexadecimal value for terminator character
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-08-16 05:50:13