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
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).
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.
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 \HELLO\
- 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.
SHOW SYMBOL displays the symbol passed as the parameters (wildcards * and % can be used) or all symbols if /ALL is used.