EasyManua.ls Logo

IBM 1620 - IF Statement for Conditional Logic

IBM 1620
111 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
IF
Statement
IF
(SENSE SWITCH)
Statement
The
IF
statement
permits you to transfer
the
program
to a particular
statement
depending
upon
the
value of
an
expression.
Format:
Example:
"IF
(a) n
1
, n
2
,
n/'
where
a is an expression
and
n
j
n
z
and
n,1
are
statement
numbers.
The
expression
must
be
enclosed
in
parentheses.
The
state-
ment
numbers
must
be
separated
from
each
other
by
com-
mas.
IF
(A
-
B)
10,
5,
7
IF
(A(I)/D)
1,2,3
The
program
is transferred to
statement
number
n
1
, n
z
,
n;J,
depending
upon
whether
the
value of
the
expression a is less than,
equal
to, or greater
than
zero,
respectively.
In
the
first example,
if
both
A
and
B have
the
value of
2,
the
program
is
transferred to
statement
number
5.
In
the
second example,
if
the
result of
the
expression is greater
than
zero, the
program
is transferred to
statement
number
3.
Suppose a value,
HRS,
is
being computed.
Whenever
this value
is
positive,
the
main routine of
the
program should
be
followed.
Whenever
the
value of
HRS
is
negative, an alternative routine starting
at
statement
12
is
to
be
followed,
and
if
HRS
is
zero,
an
error routine
at
statement
72 is to
be
followed. This prob-
lem
can
be
written
as follows:
STATEMENT
NUMBER
FORTRAN STA TEMENT
I
5
6
7
10
15
20
25
30
35
40
45
50
55
--
I I
I
, , ,
I I
L-~.
_____ 1
__
I I
_L
...
_
HRS=,(
B+C)
/
(D**E)-
F
----L-.
_____
...L
______
..L........
IF
~LH
R 5 ) 1
1
2,
72.r
1 0
I 1 1 I 1
------L_~
I 1
,
------L.....
_I
1
I
I
I
I
I
I
I
~-
10
1 I
I
.1_~_~_
.1.
1
-'-
~-~~~~
12
~
I I
I
I
I I
I
~~~~.~
,
I
I
I
I
I
,
........J_~~_......L~
72
L 1
.1.
L
L~~~
__
l~
I 1
I I I
I
I
I
I
I
This statement permits
the
program to transfer to a particular
statement
depend-
ing
upon
the
setting of
anyone
of
the
four console program switches.
Format:
Example:
"IF
(SENSE
SWITCH
i)
n
1
,
n/'
where
i
is
the
number
of one of
the
console
program
switches,
and
n
1
and
n
z
are
statement
numbers.
The
parentheses, enclosing
the
words
SENSE
SWITCH,
and
the
commas, separating
the
statement
numbers,
are
required
punctuation.
IF
(SENSE
SWITCH
3)
14, 50
IF
(SENSE
SWITCH
1)
20, 40
Writing
the
1620
FORTRAN
Program 25

Other manuals for IBM 1620

Related product manuals