Control Of Random Access Files - Sharp MZ-80B Basic Manual

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents

Advertisement

8

1 . 4 Control of random access files

A random access f ile is a dat a file which permit s dat a t o be recorded or recalled u sing t he "random
access" met hod. The t erm "random access" refers t o t he process of recording or recalling each dat a
it em by specifying it as an array element . Unlike sequ ent ial access fi les, random access fi les permit
addressing any d at a element s inclu ded in a collect ion o f dat a.
The PRINT # and INPUT # st at ement s u sed in random access st at ement s cont ain an "expression"
which specifies t he array element s following t he logical nu mber, as shown below. This is becau se ran­
dom access fi les requ ire designat ion of t he arrays of dat a of which t hey are composed .
PRINT #n (expression) , dat a
INPU T #n (expression) , variable
The "expression" mu st be given as a nu merical val u e or variable. The st at ement
INPUT #7 (2 1 ) , A $
for example, commands t he syst em t o read t he 2 1 st dat a element of a grou p i n a random access file
opened wit h logical nu mber #7 int o variable A $ .
Not e t hat random dat a access requ ires t hat every dat a it em be recorded i n a fixed lengt h. I n ot her
words, random access files requ ire recording nu meric and st ring variables in 3 2 byt es or less.
expression
I
2
Random
access
3
file
4
5
6
Nu meric variables, inclu ding t hose expressed in exponent ial not at ion , do not u su ally exceed 3 2
byt es, whereas st ring variables may ext end u p t o 2 5 5 byt es. St ring variables exceeding 3 2 byt es can­
not be recorded in one dat a element of a random access file.
Anot her difference bet ween random and sequ ent ial access f i les is t hat a random fi le can be ex­
panded af t er it has been init ially creat ed. Given random access fi le " RND
pression" of 20, for inst ance, t he file may be expanded t o accomm odat e 3 0 "boxes" when dat a is
newly ent ered wit h t he " expression" set t o 3 0.
t
Array element designation
3 2 bytes
String "ABCDEFGHI"
String "ABC"
1"
recorded u sing an " ex ­

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents