Every file in a program has implicitly associated with it a "buffer vari-able". This is the variable through which data is passed to or from a file. The file component at the current position of the file can be read into the buffer variable or the next item to be written to the file may be assigned to the variable and then written. The buffer variable, which is of the same type as the file base type, is denoted by following the file identifier with a caret
(A).
The file identifier appearing beforeModel
64817A HP64ooo
HOST Pascal
Operators
Operators are used within expressions to specify certain actions on one or more operands, and to create a new value. The value is determined by the operator, its operands, and the definition of the effect of the operator. With each operator is associated the following:
a. number, order, and type of operands b. result type
c. precedence
Operator precedence is used to determine the order of element evaluation in an expression. The higher precedence operators are evaluated first.
Grouping of operators can alter the precedence value of the group;
however, precedence within the group still follows the rules of precedence. The following list shows operators with their order of precedence, from highest to lowest.
NOT
* /,
DIV, MOD,AND
+, - OR
<, <=, <>,
=,
>=, >, INOperators may either be predefined or user-defined. Predefined operators are the arithmetic, boolean, set, string, and relational operators, and the predefined functions. User-defined operators are references to user-written functions, routines that compute and return a value. The value resulting from any operation may in turn be used as an operand for another operator.
Arithmetic Operators
Arithmetic operators take numeric operands and produce a numeric result.
A numeric type is the type REAL, LONGREAL, INTEGER, or any INTEGER sub-range. If either operand is REAL or LONGREAL, the result will be of type LONGREAL. If both operands are integers, the result will be a two-word INTEGER. Operands are converted to match the type of the result before operation takes place. Integer values, for example, are converted to real values before an operation involving integer and real numbers.
In the case of real division (/), if both operands are integers, the operands are converted to REAL type before division takes place. The result is of type LONGREAL.
Operands for both DIV and MOD must be integers.
Integer division (DIV) calculates the truncated quotient of two integers.
The sign of the result is positive if both operands have the same sign, and negative if the operands have opposite signs.
A div Bis equivalent to trunc (A/B).
Model
64817A HP64ooo
HOST Pascal
For the MOD operation, the sign of the result is always positive. I MOD J is defined only for j > 0. An error occurs if j <= 0.
A mod Bis equivalent to (A - (k
*
b)) for integer k such that 0 <=A mod B < B, where B > 0.Boolean Operators
The Boolean operators perform logical functions on Boolean operands. The Boolean operators are: NOT, AND, OR.
NOT
The NOT operator takes one Boolean operand and produces a Boolean result equal to the inverse of the operand.
AND
The AND operator yields a Boolean result of true only if all operands are true.
OR
The OR operator yields a Boolean result of true if any one of the operands is true; or yields a Boolean result of false only if all of the operands are false.
a b NOT a aANDb a OR b
T T F T T
T F F F T
F T T F T
F F T F F
All Boolean expressions are evaluated using either partial or full evaluation, depending on the setting of the PARTIAL EVAL option. The default state of the PARTIAL EVALuation option is off; however, the op-tion may be changed at any time in the program.
Under PARTIAL EVAL, the evaluation proceeds from left to right. The evaluation ceases for the AND operator when a "false" boolean value is
Model
64817A HP64ooo
HOST Pascal
Set Opera tors
Three infix operators are defined which manipulate two expressions having compatible set types and result in a third set. The set operators are:
set union (+), set difference (-), and set intersection
(*).
Set Union
The union operator creates a set whose members are all of those elements present in the first set plus those in the second set. Simply, the com-bining together of two sets into one set.
Set Difference
The difference operator creates a set whose members are those elements that are members of the first set but are not members of the second set.
Set Intersection
The intersection operator creates a set whose members are all of those members present in both sets.
The two operands of a set operator must be expression compatible. The distance between the lower and upper bounds of a set's base type is referred to as "width". One set is wider than a second set if every ele-ment in the second set is represented in the first.
Example:
set of 0 .. 100 is wider than set of 1 .• 10.
The result of a set operation is a set whose lower bound is the minimum of the lower bounds of its two operands, and whose upper bound is the maximum of the two upper bounds. Before the set operation is performed, if either operand has a width other than the result's width, it is auto-matically widened prior to the operation.
Example:
TYPE
VAR
HIGH= SET OF 50 .. 100;
LOW= SET OF 1 .. 10;
CROSS= SET OF
5 .. 75;
pos:HIGH;
neg:LOW;
crs:CROSS;
Model
64817A HP64ooo
HOST Pascal
The result of the expression (neg + pos) is a set whose base type is the range 1 .. 100. The result of the express ion ( crs + pos) is the range
5 ..
100.Narrowing of sets is also automatic for set assignments and actual value parameters. Run-time range checks are made to verify that the narrowing of a set does not discard any elements. For example, in the assignment crs := crs + pos, the result of the union is of the type SET OF