Next. DORIC 9.65, INFO-Text software
Pubblicità
Pubblicità
NEXT
NEXT O
FF relate_# ... [
P
ARALLEL]
A
LL [label_name] relate_# ... [
N
EW] [label_name]
controls the positioning and processing of related data files. The
NEXT command is particularly useful for processing related data files that do not have a one-to-one correspondence between records. A single NEXT command can position up to nine related files.
arguments
[OFF] is used only in odd-numbered program sections and interactive sessions to end NEXT processing.
[relate_# ...] the relate number(s) of the file(s) to be processed.
[PARALLEL] is used only in odd-numbered program sections and interactive sessions to request parallel advancement of the related data files. If any one of the files fails to match, INFO ends processing of the currently selected record and begins processing the next selected record.
[ALL] is used only in even-numbered program sections and input forms to begin NEXT processing for all related data files in the even-numbered section.
[NEW] is used only in even-numbered program sections and input forms to instruct INFO to leave the related data file positioned to the currently related record — even if that record is not a correct match — after an unsuccessful attempt to reposition the related file. If you do not include the NEW option, INFO re-reads the previous related record after an unsuccessful NEXT.
INFO Reference Manual Commands 365
NEXT notes
[LABEL] label-name is used only in even-numbered program sections and input forms and must be the last parameter. On a match, control will be passed to this label
(see LABEL command), rather than to the first statement in the even-numbered program section or the following statement in the input form. If no match is detected control will be passed to the following statement in both evennumbered program sections and input forms.
n
An unqualified NEXT command uses NEXT processing on the first related datafile (RELNO 1) only.
n
If MODE SET EXACT (See MODE command) is on for a related file INFO will permit a partial key match determined by the value in the common related item.
When used with the FIRST and NEXT commands with blank in the selected record key, INFO positions to the first record in the related file(s) using FIRST, then can read the whole file(s) using NEXT. Using the same technique with a
‘B’ in the selected record key, INFO positions to the first record in the related file(s) whose relate item begins with
‘B’, then can read all the related records which also meet this criteria.
n
INFO performs NEXT processing differently in evennumbered program sections to that in odd-numbered sections and interactive sessions, as described below.
For NEXT to function properly, ensure that all related files are sorted in ascending sequence on the relate key item before you issue the NEXT command. See the RELATE command reference for information about relating data files.
Note that only the following commands use the NEXT matching procedure during processing, when the commands are preceded by a NEXT command in the command stream:
CALCULATE
CONCATENATE
DISPLAY
EXPAND
LIST
MOVE
REPORT
SPECIAL FORM
366 Commands INFO Reference Manual
discussion
NEXT in even-
numbered.
program
sections
NEXT
For each selected record processed by one of the above commands, INFO repositions the specified related file, looking for a record that matches the relate key item. If a no-match condition occurs in the related file, then INFO performs standard error processing. (See Section 2, the
RELATE command, for information about error handling for related data files.)
The NEXT command controls the processing and positioning of the records of up to nine related data files.
By default, INFO processes only the first related file record that matches a selected record. The NEXT command instructs INFO to read the next record in the related data file to see if that record also matches the selected record.
To process more than one related file, enter the relate number (defined in the RELATE command discussion) for the first file to be processed, followed by the relate number of the second file to be processed, and so on.
In even-numbered program sections, INFO executes the entire command sequence for each selected record.
The NEXT command first positions to the next record in each specified related data file and then examines the related record to see if it matches the selected record.
If the values of the related item match in the selected and related records, processing resumes at the first command in the even-numbered program section, unless the LABEL option is specified in which case processing proceeds to the specified label. If a related record fails to match, the command that follows the NEXT command is executed.
Be aware that INFO re-reads the previous related record
(that is, the matching record for that file) after a no-match condition is found. Specify the option NEW to bypass the re-read, leaving the mismatched record in the buffer. (See
also the FIRST command discussion for information about how to reposition to the first record for which the relate key item matches.)
INFO Reference Manual Commands 367
NEXT
NEXT in odd-numbered program sections and interactive use examples
In even sections and input forms the NEXT and FIRST commands may include a <label> as the last parameter.
Control will be passed to this <label> rather than, in the case of NEXT, to the first statement in the even section on a match. NEXT and FIRST within an Input Form, by default, simply drop through to the next statement, as in an even section on a no-match condition.
In odd-numbered program sections or interactive sessions,
INFO processes all selected records for each command before proceeding to the next command. Because of this, you can use the NEXT command to Instruct INFO how to process a related data file when more than one related record matches the selected record.
After processing a matched set of records, INFO advances the related file to the next record. If the next related record also matches, the new set of records is processed.
INFO continues in this manner until a no-match condition occurs. When a no-match occurs, INFO repositions the related file back to the first record in the group of matching records just processed, then obtains the next selected record and continues processing in the same manner.
If more than one related data file is named in the NEXT command, INFO processes each file, as described above, in the order specified. For example, the command NEXT
3 2 1 processes all records that match the relate key item in the third related file before positioning the second related file, then processes all records that match the relate key item in the second related file before positioning the first related file, as illustrated below.
To illustrate NEXT processing, consider a selected data file named FILEX and two other data files, FILEY and
FILEZ. These files are related by the relate key item,
KEY, and contain records with key values, as indicated below:
368 Commands INFO Reference Manual
NEXT
F I L E X F I L E Y F I L E Z
RECORD # KEY RECORD # KEY RECORD # KEY
1 A 1 A 1 A
2 B 2
3 B 3
B
B
2
3
A
B
4 C 4
5 D 5
C
D
4
5
C
C
By default, INFO processes the first related file record that matches a selected record. Results of a LIST are as follows:
ENTER COMMAND > LIST KEY,$1KEY,$2KEY
$RECNO KEY KEY KEY
1 A A A
2 B B B
3 B B B
4 C C C
NO MATCH IN RELATED DATAFILE 2 FOR RECORD 5
5 D D
The following list shows how INFO is matching the records
FILEX RECORD# FILEY RECORD# FILEZ RECORD#
1 1 1
2
3
2
2
3
3
4
5
4
5
4 unmatched
INFO Reference Manual Commands 369
NEXT
370
If the following sequence of commands executes using these three files, INFO uses the NEXT command to match the records as shown below.
SELECT FILEX
RELATE FILEY 1 BY KEY
FILEY is RELATE 1
RELATE FILEZ 2 BY $1KEY
FILEZ is RELATE 2
NEXT 2 1
LIST KEY,$1KEY,$2KEY
$RECNO KEY KEY KEY
1 A A A
1 A A A
2 B B B
2 B B B
3 B B B
3 B B B
4 C C C
4 C C C
NO MATCH IN RELATED DATAFILE 2 FOR RECORD 5
5 D D
The following list shows how INFO is matching the records.
FILEX RECORD# FILEY RECORD# FILEZ RECORD#
1 1 1
1
2
1
2
2
3
2
3
3
4
4
5
3
2
3
4
4
5
3
3
3
4
5 unmatched
If you include the PARALLEL option, INFO advances the related files together after it processes each set of matching records. When a no-match condition occurs on one or more of the related files, INFO reads the next selected record, performs standard positioning on the related files, then advances the related files in parallel until another no-match condition occurs. The same files
Commands INFO Reference Manual
NEXT
used in the above example would yield the following groups of records when processed by NEXT with the
PARALLEL option:
FILEX RECORD# FILEY RECORD# FILEZ RECORD#
1 1 1
2
3
2
2
3
3
4
5
4
5
4 unmatched
INFO Reference Manual Commands 371
Scarica
Pubblicità