Appendix E: Symbols, Data, and Expressions


By Paul C. Anagnostopoulos and Steve Hoffman

This appendix begins an examination of DCL facilities that make it useful as a general-purpose programming language. The focus of this appendix is on data and the manipulation of data.

Symbols

A symbol is the DCL equivalent of what most programming languages call a variable. A symbol is a named entity with which you can associate an item of data. Later on, the data can be retrieved and manipulated by using the name to refer to it. The item of data is called the symbol's value. The same symbol may have different values at different points in the program. It is the ability of a symbol to take on different values that makes it such a powerful programming tool. A DCL symbol has three items of information associated with it:

  • Name Each symbol has a name that is used to refer to it. The name of a symbol, together with its level, uniquely distinguishes if from all other existing symbols.

  • Level Each symbol has a level, which is determined by the context in which the symbol was originally created. The various symbol contexts are described in Section 3.3. A symbol with the same name may exist in two different contexts, but duplicate names may not exist in the same context.

Therefore, a symbol's name and level uniquely distinguish it from all other symbols.

  • Value Each symbol has a value associated with it. The value is an item of data that can be manipulated by referring to it by way of the symbol's name. In other words, the symbol name acts as a "handle" for the data item.

A symbol name is composed of letters, digits, dollar sign ($), and underscore (_), but its first character cannot be a digit. Use of the dollar sign is reserved to DIGITAL. Youmay type a symbol name in lowercase or uppercase letters; DCL converts the name to uppercase before doing anything with it. A symbol name is limited to 255 characters in length. The symbol value is an item of data, associated with the symbol, that can be accessed using the symbol name. In DCL, data items can be integers or character strings.

Here is a simple example to illustrate the creation of a symbol:

     $ sym1 = 42 

This is an assignment command, which creates a new symbol. The symbol has the four-character name SYM1, a level determined by the context of the assignment command, and the value 42, which is an integer. Once a symbol is created, its value can be replaced with a new value by performing another assignment command:

     $ sym1 = "I'd rather be sailing" 

This command does not create a new symbol but rather replaces the existing symbol's value with the character string "I'd rather be sailing". An assignment command creates the symbol if it does not already exist and then sets it to the value specified on the right-hand side of the command.

It is difficult to fully appreciate the power of symbols without some further background. The rest of this chapter describes symbols, data items, and assignment commands in detail.




Getting Started with OpenVMS System Management
Getting Started with OpenVMS System Management (HP Technologies)
ISBN: 1555582818
EAN: 2147483647
Year: 2004
Pages: 130
Authors: David Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net