HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4-: 3
past the beginning of file marker is negative.
Examples
The following program shows the use of the ADVANCE statement. Line 15
positions the datum pointer at datum 1, that is, the first datum in the
file. Line 20 advances that pointer 6 datums, to datum 7. Lines 30-40
read and print that record. Datum 7 is the first field in record 4.
Line 50 positions the back at datum 4. (The READ in line 30 advanced the
pointer to datum 8). Lines 60-70 read and print that datum.
>list
! ADVANCE
5 DIM A$[30]
10 ASSIGN #1 TO "Datafile"
15 POSITION #1;BEGIN
20 ADVANCE #1;6
30 READ #1;A$,Rec_no
40 PRINT A$,Rec_no
50 ADVANCE #1;-4
60 READ #1;Rec_no
70 PRINT Rec_no
80 ASSIGN * TO #1
>run
This is record number 4
2
>
ASSIGN
The ASSIGN statement opens a file (makes it accessible) or closes a file
(makes it inaccessible) in the program executing the statement. The file
is opened by HP Business BASIC/XL when the program assigns the file a
file number. HP Business BASIC/XL uses the file number to identify the
file for reading and writing information. The ASSIGN statement
disassociates a file from its file number and closes the file. When HP
Business BASIC/XL closes a file, it releases the buffer space that was
allocated to it.
Syntax
To open a file:
{
fname
TO
#fnum
} [,RESTRICT[=]
ioaccess
]
ASSIGN {
#fnum
TO
fname
} [,STATUS[=]
num_var
] [[,
useraccess
] ]
[,MASK[=]
str_expr
]
To close a file:
{* TO
#fnum
}
ASSIGN {
#fnum
TO *}
Parameters
fname
A string literal or string expression that contains the
file name. It must include the lockword used when the
file was created, if any. This parameter can be back
referenced to a file equation.
fnum
The file number that HP Business BASIC/XL uses to
identify the file. It evaluates to a positive short
integer. If
fnum
is associated with another open file,
the ASSIGN statement opening the file first closes the
open file before opening the one specified by
fname
.
If you attempt to close an already closed
fnum
, the
ASSIGN statement does nothing.
num_var
A variable that returns the status of the ASSIGN
statement. The ASSIGN statement sets the value of this
variable to zero if it opens the file successfully;
otherwise, it sets it to a nonzero value.