FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-9
ASSIGN Statement
Examples
In the following example, the expression BALES * 345.87 is evaluated, converted to a
double precision number, and stored in the variable WEIGHT.
DOUBLE PRECISION weight
weight = bales * 345.87
In the following example, the variable X is typed as a logical variable and assigned a
logical value of .TRUE..
LOGICAL x
x = .TRUE.
The following example stores in FULLNAME the concatenation of the characters
stored in FIRST, a blank character, the characters stored in LAST, a comma, a blank,
and the first character of MIDDLE.
CHARACTER*10 full*25, first, last, middle
fullname = first // ' ' // last // ', ' // middle(1:1)
Note that the concatenation produces a 24-character string which is stored in
FULLNAME, but, because FULLNAME has a declared length of 25 characters,
FORTRAN stores a blank character after MIDDLE(1:1).
ASSIGN Statement
The ASSIGN statement assigns the value of a statement label to an integer variable.
You can use the ASSIGN statement to specify the label of an executable statement
(see the GO TO Statement on page 7-55), or to specify the label of a FORMAT
statement.
label
is the label of an executable statement or a FORMAT statement in the same
program unit as the ASSIGN statement.
name
is the symbolic name of an integer variable. It cannot be an array element.
Considerations
You must define a variable with a statement label value before you reference it in an
assigned GO TO statement or as a format identifier in an I/O statement. (See the GO
TO Statement on page 7-55.) These two uses are the only valid means of referencing
a variable to which you have assigned a statement label.
ASSIGN label TO name