Find difference between 2 flds
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Find difference between 2 flds
Hello forumer's, (??)
I have seen and this:
http://forums.runrev.com/phpBB2/viewtop ... =7&t=16184
with it's nifty split/combine but now I need the difference between 2 fields
fld 1
Hello
World
Red
fld 2
World
Blue
Hello
Green
Note that there are duplicates but not in the same order and differences.
I think I'd like an output
fld 1 -Blue, -Green
fld 2 -Red
or maybe the other way, doesn't matter
fld 1 Red
fld 2 Blue,Green
I'm sure there is some kind of nifty array method to do this.
Any ideas?
Simon
Edit (Bad Post!)
I have tried using an array but can't get my head around the different order.
I can do this with lineOffset but thought I could learn more about array manipulations for larger datasets.
And yes I'd dump the fields into variables first.
I have seen and this:
http://forums.runrev.com/phpBB2/viewtop ... =7&t=16184
with it's nifty split/combine but now I need the difference between 2 fields
fld 1
Hello
World
Red
fld 2
World
Blue
Hello
Green
Note that there are duplicates but not in the same order and differences.
I think I'd like an output
fld 1 -Blue, -Green
fld 2 -Red
or maybe the other way, doesn't matter
fld 1 Red
fld 2 Blue,Green
I'm sure there is some kind of nifty array method to do this.
Any ideas?
Simon
Edit (Bad Post!)
I have tried using an array but can't get my head around the different order.
I can do this with lineOffset but thought I could learn more about array manipulations for larger datasets.
And yes I'd dump the fields into variables first.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Find difference between 2 flds
Hi Simon,
here is a way to find unique entries in each of two lists. I uses the "split ... as list" variant of split.
Then it deletes indexes (variables) from the two arrays crosswise to arrive at the unique indexes in each of the arrays.
Kind regards
Bernd, a forumer
here is a way to find unique entries in each of two lists. I uses the "split ... as list" variant of split.
Then it deletes indexes (variables) from the two arrays crosswise to arrive at the unique indexes in each of the arrays.
Code: Select all
on mouseUp
put field "f1" into tF1
put field "f2" into tF2
-- split with return as set will use the lines of the list as index
split tF1 with return as set
split tF2 with return as set
-- create a copy of the arrays to work on for the result, see below
put tF1 into tF1Res
put tF2 into tF2Res
-- delete every index in tF2 that is also in tF1 (= duplicates)
repeat for each key aKey in tF1
delete variable tF2Res[aKey]
end repeat
-- now delete every index in tF1 that is also in tF2 (= duplicates)
repeat for each key aKey in tF2
delete variable tF1Res[aKey]
end repeat
put "unique in field 1 compared to field 2: " & cr & the keys of tF1Res into field "fRes"
put cr & cr & "unique in field 2 compared to field 1: " & cr & the keys of tF2Res after field "fRes"
end mouseUp
Bernd, a forumer

Re: Find difference between 2 flds
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:24 pm, edited 2 times in total.
shiftLock happens
Re: Find difference between 2 flds
Thank You!
Bernd,
"delete variable tF2Res[aKey]" that is what I was looking for, couldn't get my head around it.
Hermann,
I remember this stack when it was first posted, impressive stuff. I have to improve my filing technique.
Thanks again,
Simon
Bernd,
"delete variable tF2Res[aKey]" that is what I was looking for, couldn't get my head around it.
Hermann,
I remember this stack when it was first posted, impressive stuff. I have to improve my filing technique.
Thanks again,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Find difference between 2 flds
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:25 pm, edited 1 time in total.
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Find difference between 2 flds
I think I missed something: is RevOnline not working now?[-hh] wrote:Hope you and others will open their archive of posted stacks and helpful snippets, with tags to make them findable.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Find difference between 2 flds
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:25 pm, edited 1 time in total.
shiftLock happens
Re: Find difference between 2 flds
RevOnline does work very well for me in 6.6.2 RC3.
The problem seems to be that hanging/not working is different for different users and the bug(s) are difficult to reproduce. But I hope it is getting there. I did not try to upload via LC 6.6.2 RC3 yet.
Bug 11387
Kind regards
Bernd
The problem seems to be that hanging/not working is different for different users and the bug(s) are difficult to reproduce. But I hope it is getting there. I did not try to upload via LC 6.6.2 RC3 yet.
Bug 11387
Kind regards
Bernd