Repositioning Files - IBM 5110 Basic Introduction

Table of Contents

Advertisement

92
REPOSITIONING FILES
You may have an occasion to use an input file or an output file more
than once in the same program. The RESET statement allows you to
reposition the file without deactivating it (deactivation is necessary
only when the function of a file is changed from input to output or
vice versa). For example:
0020 OPEN FL4,'ESO',4,IN
0030 GET FL4,X,V,Z,Q,R,S
0100 RESET FL4
0110 GET FL4,X,V,Z,Q,R,S
0150 RESET FL4
0160 GET FL4,X,V,Z,Q,R,S
Between statements 0030 and 0100, the variables X, V, Z, Q, R, and S
could be used in one set of calculations and their values changed. By
repositioning the file, the original values in the file could again be
made available and put into variables X, V, Z, Q, R, and S for different
calculations or uses between statements 0110 and 0150, and again
between statement 0160 and the end of the program. Actua"y, the
RESET statement used in this way functions for files in the same way
that the RESTORE statement functions for the data table created by
the DATA statement.
To add data to the end of the file, you can reset it to its end by using
the RESET statement with the END keyword:
0200 RESET FL 1 END
This statement positions FL 1 to the end of the last data item in the
file. PUT statements appearing after statement 0200 will place
additional values in the file. In effect, RESET END allows you to build
onto a file. (See RESET Statement in the IBM 5110 BASIC Reference
Manual, SA21-930S.)
o
J . . . .
"
}'
92
REPOSITIONING FILES
You may have an occasion to use an input file or an output file more
than once in the same program. The RESET statement allows you to
reposition the file without deactivating it (deactivation is necessary
only when the function of a file is changed from input to output or
vice versa). For example:
0020 OPEN FL4,'ESO',4,IN
0030 GET FL4,X,V,Z,Q,R,S
0100 RESET FL4
0110 GET FL4,X,V,Z,Q,R,S
0150 RESET FL4
0160 GET FL4,X,V,Z,Q,R,S
Between statements 0030 and 0100, the variables X, V, Z, Q, R, and S
could be used in one set of calculations and their values changed. By
repositioning the file, the original values in the file could again be
made available and put into variables X, V, Z, Q, R, and S for different
calculations or uses between statements 0110 and 0150, and again
between statement 0160 and the end of the program. Actua"y, the
RESET statement used in this way functions for files in the same way
that the RESTORE statement functions for the data table created by
the DATA statement.
To add data to the end of the file, you can reset it to its end by using
the RESET statement with the END keyword:
0200 RESET FL 1 END
This statement positions FL 1 to the end of the last data item in the
file. PUT statements appearing after statement 0200 will place
additional values in the file. In effect, RESET END allows you to build
onto a file. (See RESET Statement in the IBM 5110 BASIC Reference
Manual, SA21-930S.)
o
J . . . .
"
}'

Advertisement

Table of Contents
loading

Table of Contents