From VSI OpenVMS Wiki
Revision as of 12:01, 28 November 2019 by Jane.doe (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A symbol is a name that represents a numeric, string, or boolean value (represented as a numeric or string value). Symbols are a CLI construct and are stored in process-specific symbol tables.

Symbols are used:

  • as command synonyms and foreign commands to simplify interaction with DCL
  • to store and manipulate data in command procedures and on the command line
  • to pass data between command procedures in a single process

Data types

Symbols can store numeric and string values; both numeric and string values can also be treated as boolean values. The value of the symbol can be a 32-bit integer or a string with 1 to 255 characters (for VAX) or 1 to 8192 characters (for Alpha and I64 systems).

Symbol table

Symbols are stored in the local and global symbol table. Local symbols are accessible from the current and nested command levels, global symbols are accessible from all command levels. The symbol table is defined by the number of equal signs in symbol assignment: single equal sign (=) stands for local symbol, double equal sign (==) stands for global symbol.

If symbols with the same name but different equivalence strings are defined in different tables, local symbols are preferred to global symbols.

Access to local and global symbol in command procedures can be controlled with the SET SYMBOL command: SET SYMBOL/SCOPE=NOLOCAL causes all local symbols defined in outer procedure levels to be treated as undefined by the current procedure level and all inner procedure levels, and SET SYMBOL/SCOPE=NOGLOCAL causes all global symbols to be inaccessible to the current procedure level and all inner procedure levels.

Symbol assignment

Symbols are assigned to equivalence strings with an equal sign (=). The following rules apply:

  • a single equal sign (=) is used for local symbol assignments, double equal sign (==) for global symbol assignments
  • a colon may be used in front of the equal sign (:= or :==) to indicate that the symbol has a string value
  • if the equivalence string is enclosed in double quotes (""), a string symbol is defined and the equivalence string is not normalized by DCL. If the equivalence string is not enclosed in double quotes but a colon is used in front of the equals sign, a string symbol is defined but the equivalence string is normalized. If the equivalence string is not enclosed in double quotes and no colon is used in front of the equals sign, but the equivalence string does not have a numeric value, an error is displayed because DCL treats the equivalence string itself like a symbol:
$ a = hello
%DCL-W-UNDSYM, undefined symbol - check validity and spelling
  • symbols can be abbreviated if an asterisk (*) is inserted in the symbol name (e.g. SY*MBOL will cause SY, SYM, SYMB, SYMBO and SYMBOL to be replaced with the value of SYMBOL)

To delete a symbol, DELETE/SYMBOL is used. By default, it works with local symbols; to delete a global symbol, specify /GLOBAL.

Displaying Symbols

SHOW SYMBOL displays the symbol passed as the parameters (wildcards * and % can be used) or all symbols if /ALL is used.

Forcing Symbol Substitution

To force a part of the command line to be interpreted as a symbol in cases when DCL does not expect it to be a symbol (such as in the middle of a string), use:

  • for a symbol on the command line:
    • a single quote before the symbol and a single quote after the symbol:
$ file = "xxx.txt"
$ type file
%TYPE-E-OPENIN, error opening DSA1:[DZELENINA]FILE.LIS; as input
-RMS-E-FNF, file not found
$ type 'file'
===Explicit content===
  • an ampersand (&) before the symbol:
SMAN43$ type &file
===Explicit content===
  • for a symbol inside of a string:
    • a double quote before the symbol and a single quote after the symbol:
SMAN43$ write sys$output "Here is your ''file'"
Here is your xxx.txt

See also