COMTRAN Reconstruction

F28-8043 · June 1960

Page 20

PDF page 26 of 124. Download the scanned PDF

The page as scanned

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

The text read off it

[page 20]

For example, if the programmer wishes to reduce the value of a data item called COUNTER to zero, he can do so by writing the instruction MOVE ZEROS TO COUNTER. This procedure will replace all previous data in COUNTER by zeros. Similarly, if he wished to erase all data in an area called AMOUNT, he could write MOVE BLANKS TO AMOUNT. In each case, the specified area will be completely filled with characters of the value named.

The names LOW.VALUE and HIGH.VALUE refer, respectively, to the lowest and highest characters in the collating sequence of the system for which the program is written.

Expressions

The words and symbols of the Commercial Translator language are combined into clauses and sentences in order to give instructions to the processor and the object program. Before considering the formation of these larger units of the language, however, it is important to examine two specialized forms of expression: arithmetic expressions and conditional expressions.

Arithmetic Expressions

An arithmetic expression is a combination of data-names, conditional expressions, and/or literals, joined together by one or more arithmetic operators in such a way that the entire expression can be reduced to a single numeric value. (An arithmetic operator is a symbol representing addition, subtraction, etc.; a list of operators is given below.) Both simple and compound names may be used in an arithmetic expression.

Consider the following examples:

A + B
GROSS.PAY - DEDUCTIONS
GROSS.SALES * COMMISSION
BEGINNING.ON.HAND + RECEIPTS - SHIPMENTS
A * (B + C) - (D / E)
TOTAL.SALES * .3

In these expressions, the symbols +, -, *, and / are arithmetic operators used to express addition, subtraction, multiplication, and division, respectively. They link together a variety of terms, including the values represented by the data-names A, B, C, GROSS.PAY, DEDUCTIONS, and the literal .3. All of these will represent specific values at object time. If the data-name GROSS.PAY, for example, should be 125.50, and if DEDUCTIONS should turn out to be 31.20, the expression GROSS.PAY - DEDUCTIONS would reduce to a value of 94.30. Similarly, if TOTAL.SALES should have a value of 12,000, the expression TOTAL.SALES * .3 would reduce to a value of 3,600.

Arithmetic expressions may be used as components of conditional expressions, clauses, and sentences, as will be shown later in this chapter. Use of an arithmetic expression will cause a computation to be performed in order to obtain the single result to which the expression can be reduced.

It was stated above that conditional expressions can also be used in arithmetic expressions. This is a specialized usage in which a test is made to determine whether or not a particular condition is met. The "truth operator" TR is used to indicate this test. It is generally used to multiply one or more terms in an arithmetic expression. Since it takes on a value of 1 if the conditions of the test are met, and a value of 0 if they are not met, it can be used to cancel a term in an arithmetic expression if a condition exists in which the term is not wanted. The method for doing this will be explained later, in the discussion of "truth functions."