This format of the @COMPARE statement causes EDT to compare all or part of two work files with one another. The results of the comparison can be sent to a work file, SYSOUT
or SYSLST
as required.
Operation | Operands | F mode / L mode |
@COMPARE | [procnr1] :lines1 WITH [procnr2] :lines2 [ ,[int1] [(int2)] [LIST [line [(inc)] ] ] ] |
procnr1, procnr2 | Numbers of the two work files that are to be compared ( |
lines1, lines2 | Line ranges that are to be compared with one another. The |
int1, int2 |
In addition, The following applies to |
LIST | Specifies where EDT is to output the result of the comparison. If If If |
line | The number of the line in the current work file which is to contain the first |
inc | Increment used to form the line numbers which follow line. If |
Before performing the comparison, EDT internally converts each line into UTF16
and compares the resulting lines as byte sequences. The lines are identical if both the line content and line length of this byte sequence are identical. The line numbers are ignored during the comparison of the files. If both work files use the same character set then this procedure is equivalent to a byte-by-byte comparison of the original lines.
It may be necessary to convert the output of the result of this comparison into a suitable character set. If the output is sent to SYSOUT
or SYSLST
then this is the character set that has been defined for SYSOUT
or SYSLST
. If the output is sent to the current work file then this is the character set defined for this work file. If no character set is defined for the current work file then output takes place using the character set of the compared work files. If these use different character sets then the output takes place in the character set UTFE
.
If the statement is interrupted with [K2] and the EDT session is continued with /INFORM-PROGRAM
then the processing of the statement is aborted and message EDT5501
is output.
EDT starts the comparison at the beginning of the specified line ranges. If EDT identifies a non-identical pair of lines then it reads forwards in the two files to try to find the next block of int2
identical lines.
In this case, EDT reads a maximum of int1
lines in each file. If, in this range, EDT identifies int2
consecutive identical lines, it aligns the two files for further comparison at this point. Otherwise, it aborts the comparison.
By choosing a suitable setting for int2
, it is also possible to cause EDT to consider multiple consecutive lines as a unit during the comparison. This can be of use in address files if the address specifications consist of multiple lines (see example 2).
If the same values are selected for int2
and int1
then EDT will not be able to find any matching line ranges in the two files if even a single pair of lines is not identical.
EDT reports the result of the comparison in the form of commented lists of line numbers.
In this case, it does not separately specify whether lines or line ranges are identical. The ranges for which a matching range has been found in the other file are identified together by EDT (provided that they contain at least int2
lines), i.e. they form pairs of matching ranges. If empty ranges are permitted then it is also possible to form pairs for the nonmatching ranges since two adjacent pairs of matching ranges are necessarily separated by precisely one pair of non-matching ranges, one of which may be empty.
EDT generates a commented list for each pair of non-matching ranges as a function of their size and location.
If both members of a pair of non-matching ranges are not empty but comprise no more than int1
- int2
lines then the ranges are considered to be different:
NON-MATCHING LINES ln ln . . . . . ln ln
If both members of a pair of non-matching ranges are not empty and one range contains more than int1 - int2
lines then the output of the above list is shortened accordingly and the comparison is aborted with the message
NOTHING SEEMS TO MATCH
If one member of a pair of non-matching ranges is empty and the other contains no more than int1
- int2
lines then the non-empty range is listed as an additional range:
EXTRA LINES IN 1ST FILE ln . . . ln
If the non-empty range is located in the second file then the output is equivalent but has a different heading:
EXTRA LINES IN 2ND FILE
If the non-empty range contains more than int1
- int2
lines and is not located at the end of the line range for comparison then the output of the above list is shortened accordingly and the comparison is aborted with the message
NOTHING SEEMS TO MATCH
If the non-empty range of more than int1 - int2 lines is located at the end of the line range for comparison then the message
REACHED LIMIT ON 1ST FILE
or
REACHED LIMIT ON 2ND FILE
Is output instead, where 1ST
or 2ND
designates the file which contains the empty range.
If no non-matching ranges of more than int1
- int2
lines are found in either file up to the end of the line range for comparison then the note
REACHED LIMIT ON BOTH FILES
is also output if a pair of non-matching ranges is located at the end of the line ranges for comparison. In contrast, if a pair of matching ranges is located at the end of the line ranges for comparison, the message
REACHED LIMIT ON BOTH FILES AT SAME TIME
is output. If both of the line ranges for comparison match fully then this is the only message to be output.
Example 1
1. @PROC 1 1. @COPY FILE=PROC-FILE.1 ---------------------------------------- (1) 7. @PRINT 1.0000 AAAAAA 2.0000 BBBBBB 3.0000 CCCCCC 4.0000 UUUUUU 5.0000 VVVVVV 6.0000 WWWWWW 7. @END 1. @PROC 2 1. @COPY FILE=PROC-FILE.2 --------------------------------------- (2) 8. @PRINT 1.0000 AAAAAA 2.0000 BBBBBB 3.0000 ZZZZZZ 4.0000 AAAAAA 5.0000 BBBBBB 6.0000 CCCCCC 7.0000 UUUUUU 8. @END 1. @COMPARE 1:1-6 WITH 2:1-7, 5(2) ------------------------------- (3) EXTRA LINES IN 2ND FILE 3.0000 4.0000 5.0000 EXTRA LINES IN 1ST FILE 5.0000 6.0000 REACHED LIMIT ON BOTH FILES 1. @COMPARE 1:1-6 WITH 2:1-7, 5(3) ------------------------------- (4) NON-MATCHING LINES 1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 NOTHING SEEMS TO MATCH 1. @COMPARE 1:1-6 WITH 2:1-7, 6(3) ------------------------------- (5) EXTRA LINES IN 2ND FILE 1.0000 2.0000 3.0000
EXTRA LINES IN 1ST FILE 5.0000 6.0000 REACHED LIMIT ON BOTH FILES 1.
(1) | The SAM file PROC-FILE.1 is read into work file 1. |
(2) | The SAM file PROC-FILE.2 is read into work file 2. |
(3) | If the examination of 5 lines in each of the two files does not reveal at least 2 consecutive identical line pairs then the comparison is to be aborted. The comparison is continued through to the end of the two files. |
(4) | The @COMPARE issued in (3) is issued again in slightly modified form. It is now necessary to find at least 3 consecutive identical line pairs. This time, EDT aborts the comparison. |
(5) | The @COMPARE issued in (4) is issued again in slightly modified form. The comparison should now only be aborted after 6 lines have been examined. It is continued through to the end. |
Example 2
This example assumes that the work files have already been filled with the corresponding data.
5. @PROC 1 21. @PRINT ------------------------------------------------------- (1) 1.0000 Donald Duck 2.0000 Am Dorfteich 11 3.0000 12345 Entenhausen 4.0000 - 5.0000 Dagobert Duck 6.0000 Schlossallee 1a 7.0000 12345 Entenhausen 8.0000 - 9.0000 Daisy Duck 10.0000 Am Dorfteich 12 11.0000 12345 Entenhausen 12.0000 - 13.0000 Gustav Gans 14.0000 Im Wiesengrund 10 15.0000 12345 Entenhausen 16.0000 - 17.0000 Gustav Gans 18.0000 Schmale Gasse 7 19.0000 12345 Entenhausen 20.0000 -
21. @END 5. @PRINT ------------------------------------------------------- (2) 1.0000 Gustav Gans 2.0000 Im Wiesengrund 10 3.0000 12345 Entenhausen 4.0000 - 5. @COMPARE 0:& WITH 1:&, 9999(4) ------------------------------- (3) EXTRA LINES IN 2ND FILE 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 EXTRA LINES IN 2ND FILE 17.0000 18.0000 19.0000 20.0000 REACHED LIMIT ON BOTH FILES 5. @ON 2 CHANGE '10' TO '13' 5. @COMPARE 0:& WITH 1:&, 9999(4) ------------------------------- (4) NON-MATCHING LINES 1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000
20.0000 REACHED LIMIT ON BOTH FILES 5.
(1) | Work file 1 is output. This is an address file. |
(2) | On return from work file 1, work file 0 is output. It contains an address (4 lines) which is to be searched for in work file 1. |
(3) | The search is performed by comparing the two files. Selecting the value |
(4) | Once the building number has been changed, the search is repeated. Since no further range of |
If the comparison is performed with @COMPARE 0:& WITH 1:&, 9999(1) instead of with @COMPARE 0:& WITH 1:&, 9999(4) then the same output is obtained for both matching and non-matching building numbers since EDT resynchronizes on the first matching line (12345 Entenhausen
).