Getting Contents of Multiple fields in order (Left-to-Right&Down)
John Patten
johnpatten at mac.com
Sat Jan 29 00:17:56 EST 2011
Hi All...
I have a card with four fields. The field can be dragged around by the user. I want to get the contents of each field and put them all in one container.
My attempt is below. I attempted to sort the list of fld locations but that is susceptible to the y coordinate being above the previous field and throwing off the sort.
Here is what I tried:
on mouseUp
-- sort item 1 of the field locations
put 1 into x
put 2 into y
put the number of lines in cd fld "data" into tCount
repeat for tCount-1
put item x of line x of cd fld "data" into tFirstTest
put item x of line y of cd fld "data" into tSecondTest
if tFirstTest > tSecondTest then
put line y of cd fld "data" & return after cd fld "sortedData"
delete line y of cd fld "data"
else
put line x of cd fld "data" & return after cd fld "sortedData"
delete line x of cd fld "data"
end if
end repeat
put line 1 of cd fld "data" after cd fld "sortedData"
delete line 1 of cd fld "data"
-- sort item 2 of the fld locations
put 1 into x
put 2 into y
put the number of lines in cd fld "sortedData" into tCount
repeat for tCount-1
put item y of line x of cd fld "sorteddata" into tFirstTest
put item y of line y of cd fld "sorteddata" into tSecondTest
if tFirstTest > tSecondTest then
put line y of cd fld "sorteddata" & return after cd fld "Data"
delete line y of cd fld "sorteddata"
else
put line x of cd fld "sorteddata" & return after cd fld "Data"
delete line x of cd fld "sorteddata"
end if
end repeat
put line 1 of cd fld "sorteddata" after cd fld "Data"
delete line 1 of cd fld "sorteddata"
--put the field contents in the user's order
put the number of lines in cd fld "data" into tCount
put 1 into x
repeat tCount
put item 3 of line x of cd fld "data" into tTargetField
put cd fld tTargetField of group "theFields" & " " after tWholeenchilada
add 1 to x
end repeat
put tWholeenchilada
end mouseUp
Thank you!
John Patten
SUSD
More information about the use-livecode
mailing list