Comparing Files
Accessing Files
107365 Tandem Computers Incorporated
4–15
Figure 4-6. Comparing Two Files (Page 3 of 3)
== If the first read was successful, read a line from the
== second file.
[#IF file1_err <= 1 |THEN|
#SET file2_prompt *start*
#EXTRACTV file2_var line2
== If the second read was successful, perform the
== comparison.
[#IF NOT file2_err |THEN|
== If the two lines do not match, display them.
[#IF NOT [#COMPAREV line1:column([f1]:[f2])
line2:column([f1]:[f2])] |THEN|
#OUTPUT File [file1] line [linecount]: [line1]
#OUTPUT *----------------------------------------*
#OUTPUT File [file2] line [linecount]: [line2]
#OUTPUT *----------------------------------------*
] == end of #IF ... #COMPAREV
] == end of #IF NOT file2_err
] == end of #IF file1_err
] == end of #LOOP
== Close the files
SINK [#REQUESTER CLOSE file1_err]
SINK [#REQUESTER CLOSE file2_err]
== Handle EOF conditions, file size mismatches, and errors.
[#CASE [file1_err]^[file2_err]
|1^1| #OUTPUT [linecount] lines compared == Normal exit;
|0^1| #OUTPUT [file1] is has more lines than [file2]
|1^0| #OUTPUT [file2] is has more lines than [file1]
|OTHERWISE|
[#IF file1_err > 1 |THEN|
#OUTPUT Error [file1_err] on [file1]
]
[#IF file2_err > 1 |THEN|
#OUTPUT Error [file2_err] on [file2]
]
]
#UNFRAME