HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4-: 73
Examples
10 LET Number=3 !Assignment: 3, to Number
20 Num1, Num2, Num3=4+6 !Assignment: 10, to Num1, Num2, and Num3
30 String$="cat" !Assignment: "cat" to String$
40 LET Str1$,Str2$= "Ab" + "CdE" !Assignment: "AbCdE", to Str1$, and Str2$
HP Business BASIC/XL accesses variables in LET statements from left to
right. If variables have not been declared, and implicit declaration is
illegal, an error occurs. If no error occurs, HP Business BASIC/XL
evaluates the expression and assigns its value to the variables, from
right to left. If the value is numeric, HP Business BASIC/XL converts it
to the type of each of the variables prior to assigning it to the
variables.
10 OPTION NODECLARE !Implicit declaration is legal
20 OPTION REAL !Default numeric type is real
30 INTEGER A !Integer A is explicitly declared
40 DECIMAL B !Decimal B is explicitly declared
50 LET A,B,C=(5+4)*3 !Real C is implicitly declared
99 END
In line 50, HP Business BASIC/XL does the following:
* Accesses A, B, and C in that order
* Evaluates (5+4)*3
* Assigns the following values in the following order:
To: The Value:
C real 27.0
B decimal 27.0
A integer 27
When HP Business BASIC/XL converts a numeric value to a numeric variable
type that has fewer significant digits than the value does, it rounds the
value first. An error occurs if the value is outside the range of the
variable type. An error also occurs if an assigned string value is too
long for it's string variable (that is, if the length of the string value
exceeds the maximum length of the string variable).
If an assignment statement has more than one variable to the left of the
equal sign, for example; A,B,C=5, and an error occurs in the middle of
the assignment statement, the variables after (or to the right of) the
error contain the new value. The variables before (or to the left of)
the error do not. The variable in which the error occurred does not
contain a new value.
In the example below, an error occurs when 80,000 is assigned to C in
line 30 (C, a short integer can have a maximum value of 32767). D and E
are assigned the value 80,000, but A, B, and C still have the value zero
following the error.
10 SHORT INTEGER C
20 A,B,C,D,E=0
30 A,B,C,D,E=80000
99 END
Multiple Assignment Statement
The multiple assignment statement is a series of LET statements,
separated by semicolons. The LET keyword can only appear in the first
LET statement.
Syntax
LET_stmt
[;
LET_stmt
]...