Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Assignment (Computational)
◄Up► ◄Contents► ◄Index► ◄Back►
─────Assignment (Computational)─────────────────────────────────────────────
Action
Evaluates an expression and assigns the result to the specified
variable.
Syntax
variable = expression
Parameter Description
variable A variable, array, array-element, or
structure-element
reference
expression Any expression
Remarks
The variable and expression types must be compatible. If the types
are not identical, the data type of <expression> is converted to
the data type of <variable>.
Logical expressions of any byte size can be assigned to logical
variables of any byte size without changing the value of
<expression>.
Examples
The following program demonstrates assignment statements:
REAL a, b, c
LOGICAL abigger
CHARACTER*5 assertion
c = .01
a = SQRT (c)
b = c**2
assertion = 'a > b'
abigger = (a .GT. b)
WRITE (*, 100) a, b
100 FORMAT (' a =', F7.4, ' b =', F7.4)
IF (abigger) THEN
WRITE (*, *) assertion, ' is true.'
ELSE
WRITE (*, *) assertion, ' is false.'
END IF
END
The program above has the following output:
a = .1000 b = .0001
a > b is true.
The following fragment demonstrates legal and illegal assignment
statements:
INTEGER i, int
REAL rone(4), rtwo(4), x, y
COMPLEX z CHARACTER char6*6, char8*8
i = 4
x = 2.0
z = (3.0, 4.0)
rone(1) = 4.0
rone(2) = 3.0
rone(3) = 2.0
rone(4) = 1.0
char8 = 'Hello,'
C The following assignment statements are legal:
i = rone(2)
int = rone(i)
int = x
y = x
y = z
y = rone(3)
rtwo = rone
rtwo = 4.7
char6 = char8
C The following assignment statements are illegal:
char6 = x + 1.0
int = char8//'test'
y = rone
-♦-