Encyclopaedia Index

LOGICAL variables


See description of logical (ie Boolean) variables in the PHENC entry on PIL

See also BOOLEAN, and LOGICAL variables in PIL, below. Each covers more or less the same ground.

Logical variables, declaration of


LOGICAL variables in PIL

The user can declare and use logical variables in the same way as INTEGERs and REALs. The default maximum number of logicals variables is 50, but this can be altered in SATLIT.

Variables are declared by the command BOOLEAN (LOGICAL already being a reserved PIL word); eg BOOLEAN(LOG1,LOG2,LOG3)

BOOLEAN variables are defaulted to F and are assigned by statements such as:
LOG1 = T
LOG2 = logical_expression

The following three kinds of simple logical_expression are permitted in PIL:

  1. T or F, signifying TRUE or FALSE respectively;
  2. Declared logical variables, eg: LOG3 = .not.LOG4
  3. Expressions of the form: numeric_expression operator numeric_expression

In this case implicit FLOATing is performed on integer values (ie the integer values are treated as real) and all FORTRAN operators are valid (ie all equalities and inequalities may be expressed); eg:


In this case a character variable enclosed by colons (:) inserts the current value of that variable into an expression. It should be noted that only the operators .EQ. and .NE. are valid in expressions of this type; eg:

CC=4.5 AB.EQ.:CC:

Simple logical_expressions can be combined with the logical operators .AND., .OR. and .NOT. to create arbitrarily complex logical_expressions.

There are two limitations to the use of logical operators:

  1. firstly there is no precedence defined, so that in the absence of brackets, evaluation is carried out from left to right. It is therefore recommended that brackets be used to remove potential ambiguity from complex logical_expressions.
  2. a .NOT. operator must not immediately follow an .AND. or .OR. without an intervening bracket. Thus CARTES.OR..NOT.NONORT is illegal and must be written as CARTES.OR.(.NOT.NONORT)

If, for example, the following PIL instructions are issued:


then the following are all valid assignments:

LOG1 = T
LOG1 = NX.EQ.2
LOG1 = NX+NY+45.GE.NX-3
LOG1 = :CH2:.EQ.:CH1:ZZ

The values of individual variables can be ascertained by typing the variable name (as with integers and reals). Alternatively, typing SEE L and gives the values of all currently- declared logical variables respectively.