COMTRAN Reconstruction

F28-8043 · June 1960

Page 46

PDF page 52 of 124. Download the scanned PDF

The page as scanned

The scan of PDF page 52 of F28-8043
Select the scan to open it at full size.

The text read off it

[page 46]

Accordingly, a truth function can be manipulated arithmetically in the same manner as any other quantity.

In the fourth of the preceding SET command examples, TR (STOCK.LEVEL LT ORDER.POINT) is a truth function. When the SET command is executed, the relation between STOCK.LEVEL and ORDER.POINT is evaluated. If the relation is true, that is, if STOCK.LEVEL is less than ORDER.POINT, then the truth function takes the value 1. If the relation is false, it becomes 0. The result of this SET command, then, is to cause the field REORDER to contain the order amount if stock level is below order point, or zero if the stock level is at or above order point.

FUNCTION-NAMES

The names of functions are used in arithmetic expressions in much the same way as data-names or literals. That is, a function-name is treated as a quantity, as in the fifth of the preceding examples of the SET command, where the square root of X is multiplied by 2 and truncated to obtain the result. There are some differences, however, between data-names and function-names. Data-names represent values which, at object time, are immediately available for arithmetic operations. Function-names, on the other hand, imply an evaluation process at object time. The evaluation is carried out by procedural statements identified by a BEGIN SECTION command (see page 56). These procedure statements deliver a value to be used in computing the value of the arithmetic expression.

SET Used with Condition Names

The SET command has a second function that is not strictly arithmetic. It provides a convenient way of changing the status of a conditional variable, i.e., a variable which has one or more conditions associated with it. When SET is used for this purpose it takes the general form:

SET condition.name

As a result of this command, the variable with which "condition.name" is associated (in the data description) is assigned the status, or value, of the specified condition.

Using the example mentioned in Chapter 2, if the current value of the variable MARITAL.STATUS is SINGLE and the programmer wishes to change it to MARRIED, he simply writes:

SET MARRIED.

This is the equivalent of writing:

SET MARITAL.STATUS = 'M'.

It is important to recognize the distinction between testing and setting the value of a conditional variable. Testing the value provides a basis for a decision but does not change the value; the testing is accomplished by using a conditional clause, IF . . . THEN. Setting a value of a conditional variable, on the other hand, causes the current value to be replaced by another of the possible values and is effected by means of the SET command.