/sys$common/syshlp/helplib.hlb PASCAL, Expressions, Examples *Conan The Librarian (sorry for the slow response - running on an old VAX) |
1. VARIABLES A variable can be in an expression: foo -'foo' is a predefined variable of some type new[1] -the first position of array 'new' rec.field -a field of record 'rec' pointer^ -the pointer variable of the pointer type 'pointer' cast::INTEGER -the variable 'cast' type cast as an integer 2. STRING CONSTANTS A string constant can have the following forms: name-string or {name-string ({constant-expression},...)}... [[name-string]] The 'name-string' is a quoted sequence of spaces, tabs, and any other printing characters. An apostrophe is expressed as ''. For example, 'hello there' is a name-string. The '{name-string ({constant-expressions},...)}... [[name-string]]' is a sequence that makes up a name-string. For example, when the list ('bell ' (7) 'character') is output to the terminal, you will see the string 'bell character' and the bell will ring (as indicated by the constant expression '(7)'). Additionally, Compaq Pascal allows string constants to be formed with double quotes. Inside of these double-quoted string constants, Compaq Pascal is able to recognize special characters that are specified with a backslash, as follows: o "\a" (Alert (bell) character) o "\b" (Backspace character) o "\f" (Forfeed character) o "\n" (New line or line feed character) o "\r" (Carriage return character) o "\t" (Horizontal tab character) o "\v" (Vertical tab character) o "\\" (Backslash character) o "\"" (Double quotation mark character) o "\'" (Single quotation mark character) o "\nnn (Character whose value is nnn, where nn is an octal number from 00 to 377.) o "\xnn" (Character whose value if nn, where nn is a hexadecimal number from 00 to FF.) 3. CONSTANT IDENTIFIER A constant identifier is an identifier of a type that can be determined at compile time. The following are examples of constant identifiers: CONST Foo = 3; Exp = 8 * 9; Func = MAX( 3, 2, 4 ); 4. EXPRESSION IDENTIFIER An expression identifier is an expression in parentheses optionally followed by a type cast structure. Examples are: ( a + b ) - 'a' and 'b' are predeclared variable identifiers ( Foo ) :: INTEGER - expression 'Foo' type cast as an integer 5. FUNCTION IDENTIFIER A function identifier is the name of a predeclared function. If the function has formal parameters, the function identifier must be followed by one actual parameter for each formal parameter listed. For example: FUNCTION Foo ( VAR n : INTEGER; start : Boolean ) : REAL; A call to function 'Foo' could look like the following: Foo( bar, TRUE ) Function 'Foo' returns a REAL value.
|