Scor­pio News

  

January–March 1987 – Volume 1. Issue 1.

Page 19 of 63

IF Statement

Two types of IF UF statement are used in FOR­TRAN – the arithmetic form and the logical form. The arithmetic IF takes the form:

IF(expression) L1,​L2,​L3 (L1,​L2 and L3 are statement numbers)

If the value of the expression is less than 0, control passes to statement no. 1, if it is equal to 0 then statement no. 2 to and if it is greater than 0, control passes to the last named statement –

IE(N-1) 3,5,7if the value of N-1 is 0 then control passes to the statement label no. 5

The Logical IF statement has an almost exact parallel in BASIC and it takes the form:

IF(logical expr.) statement

The logical expression is evaluated as .TRUE. or .FALSE.; if true, control passes to the statement immediately following otherwise control passes to the next program line. The logical expression can contain both logical and relational operators, which are defined as follows:

Logical operators

.NOT.     .AND.     .OR,     .XOR.

Relational operators
.LT.less than
.EQ.equal to
.GT.greater than
.LE.less than or equal to
.NE.not equal to
.GE.greater than or equal to

Relational operators are self explanatory but Logical operators may need a little clarification.

If A and B are logical expressions, then:

.NOT.Ais the logical opposite of A (0 bits become 1 and vice versa)
A.AND.Bthe value of this expression is the product (logical) of A and B. This implies that the value is .TRUE. if A and B are .TRUE. and .FALSE. otherwise
A.OR.Bthis produces the logical sum of A and B. In this case the value is .FALSE. if A and B are .FALSE. and .TRUE. otherwise.
A.XOR.Bthe value of this expression is the exclusive OR of A and B. Here, the value is .TRUE. if only one of A and B is .TRUE. otherwise it is .FALSE..

STOP statement

This is self explanatory. It causes program execution to cease at that point; if the form:

STOP (string of 1 – 6 characters)

is used, then the characters in the string will be printed out on the monitor and program execution then finishes.

Page 19 of 63