I have some data in table one that i need to matchup with table 2. By email address. (see attachment)
I then need to put the matching line in table 1 in table 3 and will export table 3 to a text file.
I have never used arrays before and think it would be the fastest to do this.
this is what I have so far and it seems to put them in the arrays but I have tried everything else i could find to match them and its not working.
local tFirstArray, tsecondArray
on mouseUp
set the itemdel to tab
put "" into field "text3"
put line 1 of fld"text1" & cr into fld"text3"
put fld"lc1" into tLineCt1
put fld"lc2" into tLineCt2
repeat for each line tLine in fld"text1"
put it into tFirstArray[tLine]
end repeat
combine tFirstArray by return and tab
put the number of lines of tFirstArray into fld"lc1"
repeat for each line tLine2 in fld"text2"
put it into tsecondArray[tLine2]
end repeat
combine tsecondArray by return and tab
now what???
Thank you for any help you can give.
Using Arrays to compare 2 tables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 46
- Joined: Fri Aug 02, 2013 12:14 am
Re: Using Arrays to compare 2 tables
Hi no1g8tor96 -
Here is one way to do what you want, assuming I understood your goal correctly. I haven't tested it but it should work (famous last words!):
Here is one way to do what you want, assuming I understood your goal correctly. I haven't tested it but it should work (famous last words!):
Code: Select all
on mouseUp
-- get the list of email addresses without other chars in each line
get fld 2 -- the list of emails to match against
split it by column
put it[2] into tEmailList -- now this contains only email addresses
-- get lines in original list whose emails match an email in tEmailList
put fld 1 into tOriginalList
set the itemDelimiter to tab
repeat for each line tLine in tOriginalList
if item 3 of tLine is among the lines of tEmailList then
put tLine & CR after tNewList
end if
end repeat
-- display the selected lines
put tNewList into fld 3
end mouseUp
Phil Davis
-
- Livecode Opensource Backer
- Posts: 46
- Joined: Fri Aug 02, 2013 12:14 am
Re: Using Arrays to compare 2 tables
Phil
Worked like a charm.
Thank you so much.
Michael
Worked like a charm.
Thank you so much.
Michael