Download ISAM System User`s Guide

Transcript
USING I S A M FROM WITHIN ALPHABASIC
Page 10-6
-
CODE 7
Accesses t h e index f i l e s e l e c t e d by # f i l e - c h a n n e l and
f i n d s t h e next symbolic key.
Returns t h e r e l a t i v e r e c o r d
number o f t h e data f i l e record associated w i t h t h a t symbolic
key i n p r e p a r a t i o n f o r a READ o r a WRITE t o t h e data f i l e .
If
t h i s i s t h e f i r s t access t o the f i l e a f t e r t h e OPEN statement,
i t f i n d s t h e f i r s t symbolic key i n the index f i l e .
I f this
f u n c t i o n f o l l o w s a p r e v i o u s code 1 statement, t h e f u n c t i o n
f i n d s t h e next symbolic key a f t e r t h e code 1 symbolic key. I f
t h e r e are no more keys i n the index f i l e , t h e f u n c t i o n r e t u r n s
an end-of-index-file
e r r o r (38): make no f u r t h e r accesses t o
t h e data f i l e u n t i 1 you make another I S A M c a l l t h a t r e t u r n s a
v a l i d r e l a t i v e record number.
NOTE: T h i s code performs e x a c t l y t h e same f u n c t i o n as code 2
above,
except t h a t i t r e t u r n s the symbolic key as w e l l as the
r e l a t i v e record number.
I t i s v e r y important t h a t the symbolic key v a r i a b l e t h a t
appears i n your code 7 I S A M statement be the same s i z e as o r
l a r g e r than t h e key defined i n the I S A M index f i l e .
I f the
v a r i a b l e i s smaller than the key, data f o l l o w i n g the symbolic
key i n memory w i 11 be overwritten,
damaging your running
program.
10.3
READING AND WRITING DATA I N AN I S A M DATA FILE
I S A M statements do not access data records, b u t i n s t e a d r e t u r n t h e i r
r e l a t i v e record numbers. To a c t u a l l y read o r w r i t e data records,
you
must use the AlphaBASIC READ, READL, WRITE, and WRITEL commands. When
you read o r w r i t e data i n a s p e c i f i c I S A M d a t a f i l e , AlphaBASIC
s e l e c t s t h e record t o be accessed by r e f e r r i n g t o the r e l a t i v e r e c o r d
number v a r i a b l e i n the OPEN statement f o r t h a t f i l e .
READ # f i le-channel, v a r i a b l e l , variable2,.
READL #file-channel, v a r i a b l e l , variable2,
WRITE #file-channel, v a r i a b l e l , variable2,
WRITEL #file-channel, v a r i a b l e l , variable2,
.. v a r i a b l e N
...
... vv aa rr ii aa bb ll ee NN
... v a r i a b l e N
The # f i l e - c h a n n e l i n the READ, READL, WRITE, o r WRITEL statements MUST
be the f i l e channel t h a t appears i n the OPEN statement f o r the p r i m a r y
index f i l e you want t o access.
The r e l a t i v e record number v a r i a b l e i n
t h e OPEN statement must c o n t a i n a v a l i d r e l a t i v e r e c o r d number o r an
e r r o r w i 11 r e s u l t .
READL and WRITEL o n l y l o c k t h e record i f LOKSER i s i n s t a l l e d on your
system;
on a non-LOKSER system, they perform t h e same a c t i o n s as READ
and WRITE.
However, even i f your system does n o t use LOKSER,
we
recommend t h a t you use READL and WRITEL, s i n c e t h i s w i l l promote
program s t a n d a r d i z a t i o n and w i l l make i t simple f o r you t o t r a n s f e r
your programs t o a LOKSER system a t a l a t e r date.
DWM-00100-06,
REV COO