The next is a small script to compare two folders. It does not require any
selection, it will highlight files in both panes which have the same name.
The script is not optimized for speed but yet is 2 to 8 times faster then
DO4-Intersect13.rexx. The script can be altered to highlight mismatches instead.
Code:
/*
* $VER: Comparer 1.00 (03.07.15)
*
*
* Small REXX script to compare files
* by name and select identicals.
*
* Requirements :
*
* DirectoryOpus v4.xx
*
*
* Written by BigFan
* no copyright claims on basic stuff
* and no license idiocracy
*
*/
numitem = 0
Options RESULTS
DirOpus = Address()
Address value DirOpus
Busy On
All
Status 3 /* get active pane */
actpane = result
Status 9 actpane /* get selected files */
numitems = result
If numitems = 0 | numitems = 'RESULT' Then Do
Busy Off
Exit 5
End
Do i = 1 to numitems
GetNextSelected
item = result
OtherWindow
SelectFile item 1 1 /* select file if exists */
OtherWindow
SelectFile item 0 1 /* deselect to continue with next selected */
End
/* Now corresponding files have been selected lets reselect first pane*/
OtherWindow
GetSelectedAll ';' /* get all identical files using ; as devider*/
item = RESULT
OtherWindow
Do Forever /* and parse them */
n = Pos(';',item)
If n = 0 Then Leave /* until all ; found */
Selectfile Left(item,n-1) 1 1
item = DelStr(item,1,n) /* cut processed file from selection */
End
Busy Off
Exit 0
When compare.rexx is running you'll witnes a flicker from pane switching. This is
ugly. If you want to test your scripting skills than alter it to work in
"silent" mode
Some suggestions on how to achieve this:
-use intermediate files to store your results
-use Setclip()GetClip() to store them in memory
create a simple array using stems. A stem is identified by its name and a
trailing number e.g.:
/* presume numoffiles has return value '3' and search path is 'libs:' then :*/
Do i = 1 To numoffiles
GetNextSelected
found.i = RESULT
End
this gives:
found.1 = icon.library
found.2 = rexxsys.library
found.3 = workbench.library
There are more possible solutions, like allocation of memory and write/read
directly to mem (using rexxsupport.library).
Piping might be used as well.