ADVANCE [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
ADVANCE
The ADVANCE statement moves the datum pointer of a specified BASIC DATA
file a given number of datum from its current position. Use of any other
file type with this statement results in an error.
Syntax
[{,} ]
ADVANCE #fnum; num_expr [{;} STATUS[=]num_var]
Parameters
fnum The file number that HP Business BASIC/XL uses to
identify the file. fnum is a numeric expression that
evaluates to a positive short integer.
num_expr A numeric expression that indicates the number of datum
and the direction that the pointer will move. The
absolute value of this expression is the number of datum
in the file that the ADVANCE statement moves the datum
pointer. If num_expr is positive, the datum pointer
moves ahead. If num_expr is negative, the datum pointer
moves back. Consider the first datum in the file to be
labeled number one. If the current position in the file
plus the value of num_expr is either less than zero or
greater than the total number of datum in the BASIC DATA
file, an end of file error occurs.
num_var num_var is a numeric variable that returns the status of
the ADVANCE operation. The value assigned to num_var is
zero if ADVANCE is successful. If either the beginning
or the end-of-file marker is passed, the difference
between num_expr and the number of items actually
skipped prior to reaching the file delimiter is
returned. Note that if num_expr is negative, the value
returned to num_var in the event of trying to advance
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
>
MPE/iX 5.0 Documentation