Comparing Files
Accessing Files
4–14
107365 Tandem Computers Incorporated
Figure 4-6. Comparing Two Files (Page 2 of 3)
== If a result file was specified, use it for output.
== Otherwise, use the default OUT file.
[#IF NOT [#EMPTYV results] |THEN|
#PUSH #OUT
#SET #OUT [results]
]
== Display the user's request.
#OUTPUT
#OUTPUT *---------------------------------------------------*
#OUTPUT Files compared: [file1],[file2] -- Field:<[f1]:[f2]>
#OUTPUT *---------------------------------------------------*
== Open the files.
#SET file1_err [#REQUESTER /WAIT/ READ [file1] file1_err &
file1_var file1_prompt]
[#IF file1_err = 0 |THEN|
#OUTPUT [file1] opened successfully
|ELSE|
#OUTPUT [file1] not open; file error [file1_err]
#RETURN
]
#SET file2_err [#REQUESTER/WAIT/ READ [file2] file2_err &
file2_var file2_prompt]
[#IF file2_err = 0 |THEN|
#OUTPUT [file2] opened successfully
|ELSE|
#OUTPUT [file2] not open; file error [file2_err]
SINK [#REQUESTER CLOSE file1_err] == close FILE1
#RETURN
]
== While there are no errors, read and compare lines.
[#LOOP |WHILE| file1_err = 0 AND file2_err = 0 |DO|
== Increment the line counter by 1.
#SET linecount [#COMPUTE lin 1]
== Read a line from the first file
#SET file1_prompt *start*
#EXTRACTV file1_var line1