IBM 1130 User Manual page 561

Computing system
Hide thumbs Also See for 1130:
Table of Contents

Advertisement

Section
Subsections
Page
70
40
I
20
10
Match/No Match Alpha Compare. This operation
is common to many commercial applications:
An employee time card may contain a four-
letter code describing what job he worked on,
and the program must look up a corresponding
rate.
An inventory card may contain a two-letter
code indicating unit of measure--LB, GR, EA,
etc.
The name field on eachinput card is compared
with the name field on the preceding card;
if
they
are not the same, branch to the "control break"
section of the program.
If
the fields to be compared are one or two
characters long, they may be read into a single
integer variable and compared like any other
intergers. For example,
if
their names are ITHIS
and ITHAT, the statement:
IF(ITHIS-ITHAT) 1,2,1
will branch to statement number 2 if they are iden-
tical, and statement number 1 if they are different.
The format (AI or A2) does not matter, except, of
course, that it must be the same for both.
If
the fields are longer than two characters,
they should be read into integer arrays, in Al
format, and compared with the NCOMP function.
Using the previous example, suppose ITHIS and
ITHAT are arrays, each containing ten alphabetic
characters.
IF(NCOMP(ITHIS, 1, 10, ITHAT, 1»1,2,1
will work the same as the simple IF statement
shown earlier.
Don't try to compare alphabetic fields that have
been stored as real variables. Two six-character
fields, called THIS and THAT, may be read from
a card and moved about in core just like any other
real variables; however, they cannot be compared
validly. The statement
IF(THIS-THAT)1, 2, 1
will not always branch to statement number 1 if
the two fields are different.

Advertisement

Table of Contents
loading

Table of Contents