25
The random access file prepared in that way would be as follows. If product no.
K=12, 5 data are registered in elements corresponding to array expressions 56 - 60.
Data position
a expression
~
KJl:5-4}
55
_ _ _ 56
K=12
57
58
59
60
61
N$
p
S
T
C$
d ata
..... product name
..... unit price
..... inventory count
..... total amount
..... comment
BRD
file
"STORE LIST"
In this way, then, data can be set in any specified array in the file. As a result, unlike
the sequential access file, in which data is overlaid in order from the heading, it is also
possible for there to be vacant addresses in the filed data.
And, because data can be accessed at will, it is also possible to easily rewrite data.
Use the practice problem to become accustomed to the use of the BRD file.
Problem
Let's read-out the random access file "STORE LIST" made here and read-out the
inventory data for a certain product.
The program execution is ended, however, when "0" is input.
Read out of inventory data
500
XOPEN
#7,
"STORE LI ST"
5 1 0
520
530
INPUT
INPUT
PRI NT
" pro d u c t
no.
=";
J :
I F
J
=0
THE N
700
#7( J*5-4), N$, P, S, T, C$
" NO. ";
J :
PR I NT
"p rod u c
t
n a me
"; N$
540
PR I NT
"u n
i
price
";P
550
PRI NT
"i nventory
count"
S
560
PR I NT
"t
0
t a I
a mo u n t
"; T
5 7 0
P R I N T
"c
0
mme n
t
";
C
$
580
GOTO
510
700
CLOSE
#7
710
E NO
In this way then, even for many products, the inventory data can be quickly read-out
by inputting the product number.