(view source code of txtcomp.rex as plain text)
/* Initialize RexxUtil */
Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
Call sysloadfuncs
/* Default definitions */
/* Names of files to contain differences */
f1min2 = "FILE1-2.RST"
f2min1 = "FILE2-1.RST"
/* Case sensitive compare, unless /I option is used */
case = 1
/* No header in files */
header = 0
/* Language US unless otherwise specified by /L:cc */
language = "US"
/* No line numbers unless /N option is specified */
numline = 0
/* Command line parsing */
Parse Upper Arg cmdline
Do i = 1 By 1 Until cmdline = ""
Parse Value cmdline With param.i cmdline
End
param.0 = i
cfile.0 = 0
Do i = 1 To param.0
param.i = Strip( param.i )
If Left( param.i, 1 ) = "/" Then Do
option = SubStr( param.i, 2, 1 )
Select
When option = "H" Then Do
header = 1
End
When option = "I" Then Do
case = 0
End
When option = "L" Then Do
chck = SubStr( param.i, 3, 1 )
If chck <> ":" Then Call Syntax
lng = SubStr( param.i, 4, 2 )
If lng <> "NL" & lng <> "US" Then Do
Call Syntax
End
Else Do
language = lng
End
End
When option = "N" Then Do
numline = 1
End
Otherwise Do
Call Syntax
End
End
End
Else Do
files = cfile.0 + 1
cfile.0 = files
cfile.files = param.i
If cfile.0 > 2 Then Call Syntax
End
End
If cfile.0 <> 2 Then Call Syntax
/* Select language specific message */
Call SetLanguage
/* Check if input files do exist */
If Exist( cfile.1 ) <> 1 | Exist( cfile.2 ) <> 1 Then Do
Call SysCls
Say
Call Beep 220, 250
Say infile_not_found
Say
Say any_key
Call SysCurState "OFF"
Call SysGetKey "NOECHO"
Call SysCls
Call Syntax
End
/* Check if output files already exist */
Call diffexist
/* Read first file */
Say reading_cfile_1
file.1. = ""
file.1.0 = 1
file.1.1 = LineIn( cfile.1, 1, 1 )
If Strip( file.1.1 ) = "" & Lines( cfile.1 ) = 0 Then Do
file.1.0 = 0
End
Else Do
i = 1
Do Until Lines( cfile.1 ) = 0
i = i + 1
file.1.i = LineIn( cfile.1, , 1 )
End
file.1.0 = i
End
Say cfile_1_read
/* Read second file */
Say reading_cfile_2
file.2. = ""
file.2.0 = 1
file.2.1 = LineIn( cfile.2, 1, 1 )
If Strip( file.2.1 ) = "" & Lines( cfile.2 ) = 0 Then Do
file.2.0 = 0
End
Else Do
i = 1
Do Until Lines( cfile.2 ) = 0
i = i + 1
file.2.i = LineIn( cfile.2, , 1 )
End
file.2.0 = i
End
Say cfile_2_read
/* Compare files one way */
file1minus2. = ""
file1minus2.0 = file.1.0
file2minus1. = ""
file2minus1.0 = file.2.0
Call SysCls
Say comparing_1_2
Say " 0%"
Do i = 1 To file.1.0
add2file = 1
Do j = 1 To file.2.0
If case = 0 Then Do
If Translate( file.1.i ) = Translate( file.2.j ) Then add2file = 0
End
Else Do
If file.1.i = file.2.j Then add2file = 0
End
End
If add2file = 1 Then Do
If numline = 1 Then num1minus2.i = Right( i||"; ", 8 )
file1minus2.i = file.1.i
End
percentage = ( i * 100 ) % file.1.0
Call SysCls
Say comparing_1_2
Say Right( percentage||"%", 5 )
End
Say comp_1_2_ended
Call SysCls
Say comparing_2_1
Say " 0%"
Do i = 1 To file.2.0
add2file = 1
Do j = 1 To file.1.0
If case = 0 Then Do
If Translate( file.2.i ) = Translate( file.1.j ) Then add2file = 0
End
Else Do
If file.2.i = file.1.j Then add2file = 0
End
End
If add2file = 1 Then Do
If numline = 1 Then num2minus1.i = Right( i||"; ", 8 )
file2minus1.i = file.2.i
End
percentage = ( i * 100 ) % file.2.0
Call SysCls
Say comparing_2_1
Say Right( percentage||"%", 5 )
End
Call SysCls
Say comp_2_1_ended
j = 0
If file1minus2.0 > 0 Then Do
Call SysCls
Say writing_diff_1_2
Say " 0%"
If header = 1 Then Do
Call LineOut f1min2, header_1_2
End
Do i = 1 To file1minus2.0
If file1minus2.i <> "" Then Do
If numline = 1 Then Do
Call LineOut f1min2, num1minus2.i||file1minus2.i
End
Else Do
Call LineOut f1min2, file1minus2.i
End
j = j + 1
End
percentage = ( i * 100 ) % file1minus2.0
Call SysCls
Say writing_diff_1_2
Say Right( percentage||"%", 5 )
End
Call LineOut f1min2
Call SysCls
Say diff_1_2_written
End
j = 0
If file2minus1.0 > 0 Then Do
Call SysCls
Say writing_diff_2_1
Say " 0%"
If header = 1 Then Do
Call LineOut f2min1, header_2_1
End
Do i = 1 To file2minus1.0
If file2minus1.i <> "" Then Do
If numline = 1 Then Do
Call LineOut f2min1, num2minus1.i||file2minus1.i
End
Else Do
Call LineOut f2min1, file2minus1.i
End
j = j + 1
End
percentage = ( i * 100 ) % file2minus1.0
Call SysCls
Say writing_diff_2_1
Say Right( percentage||"%", 5 )
End
Call LineOut f2min1
Call SysCls
Say diff_2_1_written
End
Say
exit
exist: procedure
Call SysFileTree arg( 1 ), "found.", "F"
Return found.0
Syntax:
Select
When language = "NL" Then Call SyntaxNL
Otherwise Call SyntaxUS
End
Return
SyntaxNL:
Call SysCls
Say
Say " ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
Say " º Programma : TxtComp º"
Say " º Versie : 2.10 º"
Say " º Auteur : Rob van der Woude º"
Say " º Rechten : Freeware, 'as is', (C) 1997-2003, Rob van der Woude º"
Say " º Datum : 31-08-1997 º"
Say " º Laatste rev. : 02-03-2003 º"
Say " º Functie : Vergelijkt 2 bestanden en cre‰ert 2 nieuwe waarin º"
Say " º slechts die regels worden gezet die ofwel van elkaar º"
Say " º verschillen in de oorspronkelijke bestanden ofwel in º"
Say " º ‚‚n van de twee ontbreken. º"
Say " º Syntax : TXTCOMP file1 file2 [/I] [/H] [/N] º"
Say " º Parameters : /I geen onderscheid hoofd- en kleine letters º"
Say " º /H plaatst kopregel met bestandsinformatie º"
Say " º /L:cc kies andere taal, cc kan NL of US zijn º"
Say " º /N zet regelnummer-referenties voor elke regel º"
Say " º Opmerkingen : TxtComp zal 2 nieuwe bestanden cre‰ren: º"
Say " º FILE1-2.RST bevat alleen die regels uit file1 die º"
Say " º ofwel verschillen van file2 of in file2 ontbreken; º"
Say " º FILE2-1.RST bevat alleen die regels uit file2 die º"
Say " º ofwel verschillen van file1 of in file1 ontbreken. º"
Say " ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
exit
Return
SyntaxUS:
Call SysCls
Say
Say " ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
Say " º Program : TxtComp º"
Say " º Version : 2.10 º"
Say " º Author : Rob van der Woude º"
Say " º Legal status : Freeware, as is, (C) 1997-2003, Rob van der Woude º"
Say " º Date : 08/31/1997 º"
Say " º Last revision : 02/03/2003 º"
Say " º Function : Compares 2 files and creates 2 new files containing º"
Say " º only those lines that were found to be either º"
Say " º different or not present at all in either of the º"
Say " º original files. º"
Say " º Usage : TXTCOMP file1 file2 [/I] [/H] [/N] º"
Say " º Parameters : /I ignores case during compare º"
Say " º /H places info in header of files to be created º"
Say " º /L:cc choose different language, cc may be NL or US º"
Say " º /N places line number references before each line º"
Say " º Remarks : TxtComp will create 2 new files: º"
Say " º FILE1-2.RST contains only those lines of file1 º"
Say " º that are either different from or absent in file2; º"
Say " º FILE2-1.RST contains only those lines of file2 º"
Say " º that are either different from or absent in file1. º"
Say " ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
exit
Return
diffexist:
Call SysFileTree f1min2, "exist1.", "F"
Call SysFileTree f2min1, "exist2.", "F"
If exist1.0 = 1 | exist2.0 = 1 Then Do
Call SysCls
Say
Call Beep 220, 250
Say diff_file_exist
Say remove_or_rename
Say
Say any_key
Call SysCurState "OFF"
Call SysGetKey "NOECHO"
exit
End
Return
SetLanguage:
Select
When language = "NL" Then Do
any_key = "Druk op een willekeurige toets . . ."
cfile_1_read = cfile.1||" ingelezen"
cfile_2_read = cfile.2||" ingelezen"
comparing_1_2 = "Inhoud "||cfile.1||" wordt vergeleken met "||cfile.2||" . . ."
comparing_2_1 = "Inhoud "||cfile.2||" wordt vergeleken met "||cfile.1||" . . ."
comp_1_2_ended = "Inhoud "||cfile.1||" vergeleken met "||cfile.2
comp_2_1_ended = "Inhoud "||cfile.2||" vergeleken met "||cfile.1
diff_1_2_written = "Verschillen tussen "||cfile.1||" en "||cfile.2||" weggeschreven"
diff_2_1_written = "Verschillen tussen "||cfile.2||" en "||cfile.1||" weggeschreven"
diff_file_exist = "Bestand "||f1min2||" en/of "||f2min1||" bestaat reeds."
header_1_2 = "; Regels die wel in "||cfile.1||" maar niet in "||cfile.2||" voorkomen."||"0D0A"X
header_2_1 = "; Regels die wel in "||cfile.2||" maar niet in "||cfile.1||" voorkomen."||"0D0A"X
If numline = 1 Then Do
header_1_2 = header_1_2||";**** Regelnummers in "||cfile.1||"0D0A"X
header_2_1 = header_2_1||";**** Regelnummers in "||cfile.2||"0D0A"X
End
infile_not_found = "Opgegeven bestand(en) niet gevonden."
reading_cfile_1 = cfile.1||" wordt ingelezen . . ."
reading_cfile_2 = cfile.2||" wordt ingelezen . . ."
remove_or_rename = "Verwijder of hernoem de bestanden en probeer opnieuw."
writing_diff_1_2 = "Verschillen tussen "||cfile.1||" en "||cfile.2||" worden weggeschreven . . ."
writing_diff_2_1 = "Verschillen tussen "||cfile.2||" en "||cfile.1||" worden weggeschreven . . ."
End
Otherwise Do
any_key = "Press any key . . ."
cfile_1_read = cfile.1||" read"
cfile_2_read = cfile.2||" read"
comparing_1_2 = "Comparing "||cfile.1||" with "||cfile.2||" . . ."
comparing_2_1 = "Comparing "||cfile.2||" with "||cfile.1||" . . ."
comp_1_2_ended = "Compare of "||cfile.1||" and "||cfile.2||" ended"
comp_2_1_ended = "Compare of "||cfile.2||" and "||cfile.1||" ended"
diff_1_2_written = "Differences between "||cfile.1||" and "||cfile.2||" written"
diff_2_1_written = "Differences between "||cfile.2||" and "||cfile.1||" written"
diff_file_exist = "File "||f1min2||" and/or "||f2min1||" already exists."
header_1_2 = "; Lines found in "||cfile.1||" but not in "||cfile.2||"0D0A"X
header_2_1 = "; Lines found in "||cfile.2||" but not in "||cfile.1||"0D0A"X
If numline = 1 Then Do
header_1_2 = header_1_2||";**** Line numbers as in "||cfile.1||"0D0A"X
header_2_1 = header_2_1||";**** Line numbers as in "||cfile.2||"0D0A"X
End
infile_not_found = "Input file(s) not found."
reading_cfile_1 = "Reading "||cfile.1||" . . ."
reading_cfile_2 = "Reading "||cfile.2||" . . ."
remove_or_rename = "Remove or rename these files and try again."
writing_diff_1_2 = "Writing differences between "||cfile.1||" and "||cfile.2||" to file . . ."
writing_diff_2_1 = "Writing differences between "||cfile.2||" and "||cfile.1||" to file . . ."
End
End
Return
page last modified: 2024-04-16; loaded in 0.0084 seconds