Array Question
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Mon Oct 2 05:53:35 EDT 2006
Hi John,
These two functions might get you started.
They return common or uncommon LINES in two lists: you will adapt
them ;-)
function CommonList plist1,plist2
local tArray1,tArray2,tCommonList
------
put empty into tArray1
put empty into tArray2
-----
repeat for each line tLine in plist1
put 1 into tArray1[tLine]
end repeat
repeat for each line tLine in plist2
put 1 into tArray2[tLine]
end repeat
-----
get the keys of tArray1
repeat for each line tLine in it
if tArray2[tLine] = 1 then
put tLine & cr after tCommonList
end if
end repeat
-----
delete char -1 of tCommonList
return tCommonList
end CommonList
-----------------------------------
function UnCommonList plist1,plist2
local tArray1,tArray2,tUncommonList
------
put empty into tArray1
put empty into tArray2
-----
repeat for each line tLine in plist1
put 1 into tArray1[tLine]
end repeat
repeat for each line tLine in plist2
put 1 into tArray2[tLine]
end repeat
-----
get the keys of tArray1
repeat for each line tLine in it
if tArray2[tLine] = 0 then
put tLine & cr after tUncommonList
end if
end repeat
-----
get the keys of tArray2
repeat for each line tLine in it
if tArray1[tLine] = 0 then
put tLine & cr after tUncommonList
end if
end repeat
-----
delete char -1 of tUncommonList
return tUncommonList
end UnCommonList
Le 2 oct. 06 à 11:30, John Miller a écrit :
> Good Morning All,
>
> I am feeling rather dense this today. I have never worked with
> arrays, and I don't seem to be able to understand how to set them up.
>
> I have two card fields with many lines and multiple items. I want
> to use the intersect command to find which lines have a particular
> item in common, but I can't figure out how to put each field into
> an array.
>
> Can anyone offer me some guidance?
>
> Thanks,
> John Miller
Best Regards from Paris,
Eric Chatonet
------------------------------------------------------------------------
----------------------
http://www.sosmartsoftware.com/ eric.chatonet at sosmartsoftware.com/
More information about the use-livecode
mailing list