MERGE
Merge Program Lines from Separate Sources
This directive allows you to combine program statements in task program memory with program statements from an INDEXED file that contains LISTed program statements, terminated with an END directive.
Syntax
Section titled “Syntax”MERGE (channel [,ERR=line-ref|,ERC=error-code] [, IND=index-num][TBL=line-ref])channel- is an integer in the range of 0 to 32764 indicating the channel of an OPEN file. If omitted, the default is 0.
line-ref- for ERR=, is the program line number or label to branch to if an error is produced by this directive. For TBL=, line-ref is the integer number of the TABLE directive to be used to convert each character before MERGEing into task program memory.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
index-num- is an integer in the range of 0 to 8388607 specifying the index number of the first record in the file OPEN on the channel to send program statements to task program memory.
Remarks
Section titled “Remarks”The MERGE directive can be used to combine two or more smaller programs into a single larger program, or for copying part of one program to another program without retyping. This is accomplished by using:
- The INDEXED directive to create an INDEXED file.
- The LIST directive to list or copy a program into this INDEXED file making certain that the last program statement listed is an END directive.
- The MERGE directive to MERGE the INDEXED file with a program in the task program memory.
Program statements are MERGEd starting at the index number specified by the IND= clause in the MERGE directive until an END directive is encountered.
Syntax errors are not reported for merged statements.
Only the copy of the program in the task memory is altered; the copy of the original program on disk and the program statements on the INDEXED file are not altered by the MERGE directive.
If the INDEXED file contains a line number that matches an existing line number in the task program memory, the INDEXED file contents replaces the original task program memory contents.
The use of the IND= clause, coupled with the fact that MERGE stops at an END directive, allows multiple program segments to be maintained in one INDEXED file.
An attempt to MERGE program statements from a file other than an INDEXED file results in an ERR=17.
An attempt to MERGE program statements from a file that does not contain an END directive results in an ERR=21.
The MERGE directive is not valid in a public program. Using MERGE in a public program generates ERR=38.
Examples
Section titled “Examples”MERGE (2)blends the program statements from the INDEXED file OPEN on channel 2 with whatever program currently exists in task program memory.
MERGE (2,ERR=07999,IND=20,TBL=00050)has the same effect as the example above, but starts reading the INDEXED file at the record with index number 20; transfers program execution to statement 07999 if an error occurs while executing this directive; and uses the TABLE directive at statement 00050 for the code conversion information.
See also
Section titled “See also”INDEXED directive
From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF