Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

@COMPARE (format 1) - Compare two work files

&pagelevel(3)&pagelevel

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 (0..22). It is also
possible to compare different ranges in the same work file (procnr1 equals
procnr2). If one of the files for comparison is work file 0 and if a file has
been opened in it for real processing with @OPEN, format 2 then
@COMPARE is rejected with the error message EDT4935. If procnr1 or
procnr2 is not specified then the value of the current work file is used for
the missing operand.

lines1, lines2

Line ranges that are to be compared with one another. The lines1 operand
defines the line range in the first work file (procnr1). The lines2 operand
defines the line range in the second work file (procnr2). Neither of these
line ranges may be empty as otherwise the statement is rejected with the
error EDT4932.

int1, int2

int1 and int2 can be used to determine how tolerant EDT is to be if it finds
non-identical lines. If EDT does not find at least int2 consecutive lines that
are identical in the two files after examining int1 lines then it aborts the
comparison.

In addition, int2 specifies how many consecutive lines in a work file must
match the corresponding number of consecutive lines in the other work file
before EDT considers the ranges consisting of these lines to be identical.

The following applies to int1 and int2: int2 <= int1 <= 65535. The
default value for int1 is 10, and for int2 it is 1.

LIST

Specifies where EDT is to output the result of the comparison.

If LIST is specified without line, EDT outputs the result of the comparison to
SYSLST. In this case, EDT outputs the line number and the first 51
characters of line content for every line for which no match is found.

If LIST is specified with line then EDT writes the result of the comparison to
the current work file unless this is one of the two files involved in the
comparison. Otherwise, the @COMPARE statement is rejected with the
message EDT4909. The line number assignment can be influenced using
the line and inc operands (see below). Only the numbers of the lines for
which no match is found are output. The line content is not output.

If LIST is not specified, EDT outputs the result of the comparison to SYSOUT
in interactive mode and to SYSLST in batch mode. The output format is the
same as for output to the current work file.

line

The number of the line in the current work file which is to contain the first
line of the result of the comparison. The format in which EDT writes the
result is the same as that used when output is sent to SYSOUT.

inc

Increment used to form the line numbers which follow line. If inc is not
specified then the increment implicitly specified by line is used (see section
“Implicit increment assignment”).

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 9999 for int1 (see the operand description) ensures that the comparison is not aborted. Selecting 4 for int2 ensures that only ranges with 4 matching lines are considered to be identical. The output identifies the presence of EXTRA LINES both before and after the matching range, i.e. the address is present in work file 1.

(4)

Once the building number has been changed, the search is repeated. Since no further range of 4 matching lines is found, only NON-MATCHING LINES are reported. The address is therefore not present.

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).