Creating A Tape Or Diskette File - IBM 5110 Basic Introduction

Table of Contents

Advertisement

90
Normally, a file is deactivated or closed by the system after execution
of your program. However, if you want to switch an input file to
output (or vice versa) and continue to use it in the same program, you
must deactivate it by using the CLOSE [FI LE] statement before
reopening it. (If you did not use the CLOSE statement and attempted
to use an output file for input or vice versa, execution of your program
would be terminated.) The CLOSE statement deactivates the file; a
subsequent OPEN statement opens (reactivates) the file for its new
use and repositions it at its beginning. Under ordinary circumstances,
the CLOSE statement is optional, and the system will close a file at the
end of program execution.
The CLOSE statement is required, however, if you use the same file
for both input and output operations in the same program. This does
not apply to record-oriented files opened with the ALL parameter (see
OPEN FILE Statement in the IBM 5110 BASIC Reference Manual,
SA21-9308). The CLOSE statement is also required if several different
files are accessed by the same program.
CREATING A TAPE OR DISKETTE FILE
The following compound interest program can be used to produce an
output listing containing 600 values in 200 lines:
o
:I. 0 0 P F<
J
,",I T
' [
(!
T F P P PIN C I P
(",I... '
o
0
:::":~
0 I N P
1...1
T
I""'
o
0 : : : : ; : 0 P P I
(I
T F
I... F' . .
'T J ti [ '.'
'P
(I
"r
E '.'
'(:",
("j [I
1...1
NT'
I)
0 q" 0 F 0
F:~
"r : : : :
:I.
T
(J
:I.
0
o
0
~:":"i
0 FOP P
~::
:I.
T U
:::~
0
0060
A~P*(1+R/l00)tT
[I
0 "/ 0 P R I N T F
I...
P..
"r..
H "' (:",
00:::::0
r\![:x:"r
I~
OO?O j\!E><T "f
0:1.00 r;TDP
The PRINT statement in this program is executed 200 times to
produce an output listing containing the values. These values could be
grouped as an output file on tape or diskette. In fact, instead of
printing them, you could store them in the file and use them later. By
adding an OPEN statement and substituting a PUT statement for the
PRINT statement (line 0070), you can create a tape or diskette file; for
example:
0025 OPEN FL 1 ,'E80',2,OUT
0070 PUT FL 1 ,T,R,A
o
o
90
Normally, a file is deactivated or closed by the system after execution
of your program. However, if you want to switch an input file to
output (or vice versa) and continue to use it in the same program, you
must deactivate it by using the CLOSE [FI LE] statement before
reopening it. (If you did not use the CLOSE statement and attempted
to use an output file for input or vice versa, execution of your program
would be terminated.) The CLOSE statement deactivates the file; a
subsequent OPEN statement opens (reactivates) the file for its new
use and repositions it at its beginning. Under ordinary circumstances,
the CLOSE statement is optional, and the system will close a file at the
end of program execution.
The CLOSE statement is required, however, if you use the same file
for both input and output operations in the same program. This does
not apply to record-oriented files opened with the ALL parameter (see
OPEN FILE Statement in the IBM 5110 BASIC Reference Manual,
SA21-9308). The CLOSE statement is also required if several different
files are accessed by the same program.
CREATING A TAPE OR DISKETTE FILE
The following compound interest program can be used to produce an
output listing containing 600 values in 200 lines:
o
:I. 0 0 P F<
J
,",I T
' [
(!
T F P P PIN C I P
(",I... '
o
0
:::":~
0 I N P
1...1
T
I""'
o
0 : : : : ; : 0 P P I
(I
T F
I... F' . .
'T J ti [ '.'
'P
(I
"r
E '.'
'(:",
("j [I
1...1
NT'
I)
0 q" 0 F 0
F:~
"r : : : :
:I.
T
(J
:I.
0
o
0
~:":"i
0 FOP P
~::
:I.
T U
:::~
0
0060
A~P*(1+R/l00)tT
[I
0 "/ 0 P R I N T F
I...
P..
"r..
H "' (:",
00:::::0
r\![:x:"r
I~
OO?O j\!E><T "f
0:1.00 r;TDP
The PRINT statement in this program is executed 200 times to
produce an output listing containing the values. These values could be
grouped as an output file on tape or diskette. In fact, instead of
printing them, you could store them in the file and use them later. By
adding an OPEN statement and substituting a PUT statement for the
PRINT statement (line 0070), you can create a tape or diskette file; for
example:
0025 OPEN FL 1 ,'E80',2,OUT
0070 PUT FL 1 ,T,R,A
o
o

Advertisement

Table of Contents
loading

Table of Contents