Numeric Array Expressions

Although not a scientific language, PRO/5 allows certain operations, such as matrix copy, add, subtract, and multiply, to be performed on entire numeric arrays. These operations are intended for use with PRO/5's graphics capabilities. Therefore, some common functions, such as matrix transpose, are not implemented. See LET Verb for complete details. Furthermore, entire arrays (numeric or string) can be read or written. See the READ and WRITE for more information.

Numeric Input

The READ, INPUT, DREAD, and INPUTN verbs may be used to accept numeric data into a numeric variable from the keyboard, from a file, or from a DATA statement. The numeric data may contain an optional sign, digits, one optional decimal point, and optional E-notation for a decimal exponent. For instance, the input "1.2E6" equals 1.2 times ten to the sixth power, or 1,200,000. Non-numeric data will cause an !ERROR=26, and the assignment will not be performed. Regardless of the current precision, no rounding is performed during input.

Numeric Input Verification

Ordinarily, any quantity PRO/5 is capable of representing may be input, and any additional validity checks are the programmer's responsibility. However, PRO/5 does provide a convenient numeric verification facility. With numeric input verification, limits may be imposed on the input value, and special branches may be taken on special input values, which need not be numeric. The syntax for numeric input verification is as follows:

numvar:({str=lineref{,str=lineref...},} {maxval})

The optional str=lineref items compare the input data, before any attempt is made to interpret it as a numerical quantity, to the specified string, and cause a branch if they match. Only string constants may be used in this context. Variables and other string expressions are not permitted. These string comparisons are case-sensitive. If no str=lineref item matches, the input must be valid numeric data, or an !ERROR=26 will occur.

The maxval item, if present, imposes limits on both the value and the precision of the input. If maxval is positive, only values between zero and maxval, inclusive, are allowed. If maxval is negative, any values from negative the absolute value of maxval to positive the absolute value of maxval are accepted. Out-of-range quantities cause an !ERROR=48.

Not only does maxval affect the range of values the input may take, but the precision as well. Integers are always accepted, but the user's input may never require more decimal places than are required to print maxval. Input data requiring more precision than maxval cause an !ERROR=48.

The following example will accept any value from -9.9 to +9.9, provided not more than one decimal place is required to print the value. If the word "END" is typed, a branch to line 100 is taken.

0010 INPUT A:("END"=0100,-9.9)

Note that an attempt to specify a maxval of 10.0, thereby setting the limit at 10, but still permitting one decimal place of precision, would fail, because the internal representations for 10 and 10.0 are identical.

Numeric input verification is done by the following sequence of events. First, the input data is obtained as a string. This value is then compared against all str=lineref items, in the order listed. If a match occurs, the branch is taken without any assignment being performed. Otherwise, the input is converted to a numerical quantity, causing an !ERROR=26 if the data is invalid. Finally, the value is assigned, and range checks are performed. With INPUTN, the process is the same, but it is the final edited string, prior to application of the output mask, that is verified.

The following example illustrates a popular technique that exploits the fact that numeric verification is done before assignment:

100 INPUT A:(""=110)

The user may enter a new value for A, or simply press RETURN and allow the current value to remain unchanged.