Skip to main content

Display (Write) Commands

Display (Write) Commands

ObjectScript supports four commands to display (write) literals and variable values to the current output device:

Argumentless Display Commands

  • Argumentless WRITE displays the name and value of each defined local variable, one variable per line. It lists both public and private variables. It does not list global variables, process-private globals, or special variables. It lists variables in collation sequence order. It lists subscripted variables in subscript tree order.

    It displays all data values as quoted strings delimited by double quote characters, except for canonical numbers and object references. It displays a variable assigned an object reference (OREF) value as variable=<OBJECT REFERENCE>[oref]. It displays a %List format value or a bitstring value in their encoded form as a quoted string. Because these encoded forms may contain non-printing characters, a %List or bitstring may appear to be an empty string.

    WRITE does not display certain non-printing characters; no placeholder or space is displayed to represent these non-printing characters. WRITE executes control characters (such as line feed or backspace).

  • Argumentless ZWRITE is functionally identical to argumentless WRITE.

  • Argumentless ZZDUMP is an invalid command that generates a <SYNTAX> error.

  • Argumentless ZZWRITE is a no-op that returns the empty string.

Display Commands with Arguments

The following tables list the features of the argumented forms of the four commands. All four commands can take a single argument or a comma-separated list of arguments. All four commands can take as an argument a local, global, or process-private variable, a literal, an expression, or a special variable:

The following tables also list the %Library.Utility.FormatString()Opens in a new tab method default return values. The FormatString() method is most similar to ZZWRITE, except that it does not list %val= as part of the return value, and it returns only the object reference (OREF) identifier. FormatString() allows you to set a variable to a return value in ZWRITE / ZZWRITE format.

Display Formatting
  WRITE ZWRITE ZZDUMP ZZWRITE FormatString()
Each value on a separate line? NO YES YES (16 characters per line) YES One input value only
Variable names identified? NO YES NO Represented by %val= NO
Undefined variable results in <UNDEFINED> error? YES NO (skipped, variable name not returned) YES YES YES

All four commands evaluate expressions and return numbers in canonical form.

How Values are Displayed
  WRITE ZWRITE ZZDUMP ZZWRITE FormatString()
Hexadecimal representation? NO NO YES NO NO
Strings quoted to distinguish from numerics? NO YES NO YES (a string literal is returned as %val="value") YES
Subscript nodes displayed? NO YES NO NO NO
Global variables in another namespace (extended global reference) displayed? YES YES (extended global reference syntax shown) YES YES YES
Non-printing characters displayed? NO, not displayed; control characters executed YES, displayed as $c(n) YES, displayed as hexadecimal YES, displayed as $c(n) YES, displayed as $c(n)
List value format encoded string $lb(val) format encoded string $lb(val) format $lb(val) format
%Status format string containing encoded Lists string containing $lb(val) format Lists, with appended /*... */ comment specifying error and message. string containing encoded Lists string containing $lb(val) format Lists, with appended /*... */ comment specifying error and message. string containing $lb(val) format Lists, with (by default) appended /*... */ comment specifying error and message.
Bitstring format encoded string $zwc format with appended /* $bit() */ comment listing 1 bits. For example: %val=$zwc(407,2,1,2,3,5)/*$bit(2..4,6)*/ encoded string $zwc format with appended /* $bit() */ comment listing 1 bits. For example: %val=$zwc(407,2,1,2,3,5)/*$bit(2..4,6)*/ $zwc format with (by default) appended /* $bit() */ comment listing 1 bits. For example: %val=$zwc(407,2,1,2,3,5)/*$bit(2..4,6)*/
Object Reference (OREF) format OREF only OREF in <OBJECT REFERENCE>[oref] format. General information, attribute values, etc. details listed. All subnodes listed OREF only OREF in <OBJECT REFERENCE>[oref] format. General information, attribute values, etc. details listed. OREF only, as quoted string

JSON dynamic arrays and JSON dynamic objects are returned as OREF values by all of these commands. To return the JSON contents, you must use %ToJSON(), as shown in the following example:

  SET jobj={"name":"Fred","city":"Bedrock"}
  WRITE "JSON object reference:",!
  ZWRITE jobj
  WRITE !!,"JSON object value:",!
  ZWRITE jobj.%ToJSON()

For further details, see WRITE, ZWRITE, ZZDUMP, and ZZWRITE.

FeedbackOpens in a new tab