User Tools

Site Tools


DCL Symbols

The term “symbol” is nothing more than an old-fashioned name for “variable” – a DCL symbol is simply a DCL variable, just as Linux/Unix shells like bash have shell variables. The term “DCL symbol” likely just comes from terminology used by the DCL software developers in the 1970s, probably related to their use of the terms “global and local symbol tables;” the term “symbol” has no more magic in it than that.

Shell variables are very useful, in scripts and on the command line itself, and DCL variables are just as useful for the same purposes. DCL variables are used for arithmetic and string computations/calculations, and as command aliases (short &/or memorable names for more complicated command verbs).

DCL variables can have two types of values (datatypes):

  • Strings (of characters), for a variety of purposes and uses.
  • Integers (whole numbers, no fractions), for arithmetic and counting.

DCL variables have scope (visibility):

  • Global symbols, created/assigned with the == (or :==) operator, are visible at any level, including on the command line (level 0) and within executing command files (scripts, level 1 and higher/deeper).
  • Local symbols, created/assigned with the = (or :=) operator, usually used and visible only within command files where created (and in nested command files).

A DCL symbol can be used as a command alias – the global variable's value is a string of characters, the first element or “word” of which is an executable DCL command; for example:

$ ls com:*.com;0

Directory DSA2:[JSMITH.COM]

BELL.COM;2                         4  20-SEP-2017 09:41:19.35  (RWED,RWED,,)
BUILD.COM;1                        1  26-JUL-1997 17:48:20.58  (RWED,RWED,RE,)
CD.COM;1                           6   9-FEB-2016 08:51:05.90  (RWED,RWED,,)
CLS.COM;10                         5  11-FEB-2016 10:41:25.45  (RWED,RWED,,)

Total of 37 files, 247 blocks.

A DCL variable can be used as a counter – this example might be found in a command file (script):

$ count = 0   ! create and initialize
$ IF count .gt. 10 THEN GOTO LOOP_EXIT
$ WRITE sys$output "Loop iteration: ", count
$ count = count + 1
$ EXIT 1

Message strings can be built-up (concatenated) using string variables:

$ Brother == "John"
$ Sister  == "Jane"
$ WRITE sys$output Sister, " & ", Brother, " are siblings."
Jane & John are siblings.

These examples only scratch the surface of what's possible with DCL variables. The best places to learn more are to read existing command files, including your system's own SYS$SYLOGIN script, your own LOGIN.COM file, and various application or utility scripts that may be available.

dcl_symbols.txt · Last modified: 2018/12/03 19:28 by lricker

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki