Download OpenVMS User`s Manual - Living Computer Museum
Transcript
Programming with DCL: Defining Symbols, Commands, and Expressions
14.8 Using Logical Values and Expressions
Therefore, the result of the expression (9 + 1) is 10 and this value is assigned to
the symbol SUM:
$ SUM = F$LENGTH("BUMBLEBEE") + 1
$ SHOW SYMBOL SUM
SUM = 10 Hex = 0000000A Octal = 00000000012
Note that each lexical function returns information as either an integer or a
character string. In addition, you must specify the arguments for a lexical
function as either integer or character string expressions.
For example, the F$LENGTH function requires an argument that is a character
string expression and it returns a value that is an integer. In a previous example,
the argument "BUMBLEBEE" is a character string expression and the return
value ( 9 ) is an integer.
You can use a lexical function in any position that you can use a symbol. In
positions where symbol substitution must be forced by enclosing the symbol in
apostrophes (see Section 14.12), lexical function evaluation must be forced by
placing the lexical function within apostrophes. Lexical functions can also be
used as argument values in other lexical functions.
The following examples show different ways you can specify the argument for
the F$LENGTH function. In each example, the argument is a character string
expression.
•
The following example shows a symbol that is used as an argument:
$ BUG = "BUMBLEBEE"
$ LEN = F$LENGTH(BUG)
$ SHOW SYMBOL LEN
LEN = 9 Hex = 00000009 Octal = 00000000011
When you use the symbol BUG as an argument, do not place quotation
marks around it. The lexical function automatically substitutes the value
"BUMBLEBEE" for BUG, determines the length, and returns the value 9.
•
The following example shows an argument that contains both a symbol and a
character string:
$ BUG = "BUMBLEBEE"
$ LEN = F$LENGTH(BUG)
$ SHOW SYMBOL LEN
LEN = 9 Hex = 00000009 Octal = 00000000011
$ LEN = F$LENGTH(BUG + "S")
$ SHOW SYMBOL LEN
LEN = 10 Hex = 0000000A Octal = 00000000012
The symbol BUG is not enclosed in quotation marks but the string "S" is. The
argument must be evaluated before the F$LENGTH function can determine
the length. The value represented by the symbol BUG ("BUMBLEBEE")
is concatenated with the string "S"; the result is "BUMBLEBEES". The
F$LENGTH function determines the length of the string "BUMBLEBEES"
and returns the value 10.
•
The following example uses another lexical function as the argument for the
F$LENGTH function. The F$DIRECTORY function returns the name of your
current default directory, including the square brackets. In the following
example, the current default directory is [SALMON].
$ LEN = F$LENGTH(F$DIRECTORY())
$ SHOW SYMBOL LEN
LEN = 8 Hex = 00000008 Octal = 00000000010
Programming with DCL: Defining Symbols, Commands, and Expressions 14–19
Related documents