Diff algorithm
Bill Vlahos
bvlahos at mac.com
Tue Nov 4 11:56:29 EST 2003
Here is a script I wrote to compare 2 folders for files and folders
that were present in each and unique to each. I never bothered to make
it recursive.
Fields "three", "four", and "five" are visible and is where the output
is sent to.
on mouseUp
prepFields -- handler in stack script to clear fields
lock screen
-- field "one" contains a directory listing for "Folder1" and is
invisible
-- field "two" contains a directory listing for "Folder2" and is
invisible
repeat for each line tLine in field "one" -- compare Folder1 against
Folder2
find string tLine in field "two" -- for each line see if you can
find it anywhere in field "two"
if the result is not empty then
put the URLDecode of item one of tLine & return after field
"three" -- Unique to Folder1
else
put the URLDecode of item one tLine & return after field "five"
-- Common to both folders
end if
end repeat
repeat for each line tLine in field "two" -- now compare Folder2
against Folder1
find string tLine in field "one" -- for each line see if you can
find it anywhere in field "one"
if the result is not empty then
put the URLDecode of item one tLine & return after field "four"
-- Unique to Folder2
end if
end repeat
sort field "five"
unlock screen with dissolve fast
end mouseUp
As an interesting aside, I wrote this as an example stack just to show
someone how to do it in Rev but never thought I would actually use it.
It wasn't 3 weeks before I was transfering files from one server to
another and I got a report that some files were not able to transfer
but it didn't say which ones. This app worked perfectly to tell me
which ones didn't make it.
Bill Vlahos
On Nov 3, 2003, at 11:21 PM, Richard Gaskin wrote:
> Anyone implement a diff algorithm in xTalk?
>
> My goal is to compare the words in two blocks of text and output a
> combined
> block of text showing words present in the first block but absent in
> the
> second ("deleted") in red with a strikeout, and words present in the
> second
> but absent from the first ("added") in blue.
>
> This is one of those things that seems simple enough, yet in looking
> at the
> various algorithms floating around the Web apparently it is not. I
> had a
> version that kinda worked on lines but only kinda, so here I am....
>
> --
> Richard Gaskin
> Fourth World Media Corporation
> ___________________________________________________________
> Ambassador at FourthWorld.com http://www.FourthWorld.com
> Tel: 323-225-3717 AIM: FourthWorldInc
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list