Getting Contents of Multiple fields in order (Left-to-Right&Down)

Jim Ault jimaultwins at yahoo.com
Sat Jan 29 14:05:14 EST 2011


On Jan 29, 2011, at 10:43 AM, J. Landman Gay wrote:

> On 1/29/11 6:12 AM, Jim Ault wrote:
>> Assuming all fields on a card are the target fields to sort and  
>> combine
>>
>> on sortFlds
>> repeat with k = 1 to the number of fields
>> put the rect of field k after fieldList
>> put comma & k after fieldList
>> put cr after fieldList
>> end repeat
>> sort fieldList numeric by item 2 of each -- Y
>> sort fieldList numeric by item 1 of each -- X
>>
>> repeat for each line LNN in fieldList
>> put fld (item 5 of LNN) after tWholeenchilada
>> put cr after tWholeenchilada
>> end repeat
>> put tWholeenchilada into msg box
>> end sortFlds
>>
>> -- in the second repeat loop you could use ...
>> -- put item 5 of LNN into fldNum
>> -- put fld fldNum after tWholeenchilada
>>
>
> I tried something almost identical and it didn't work, so I was  
> waiting to see if anyone else could come up with a solution. The  
> task is harder than you'd think at first.
>
> For testing, stagger the fields a little bit so their tops and lefts  
> aren't aligned in any way.

My test I used did have scattered fields, but if all the X values are  
different, then that becomes the sort order and the Y values have no  
effect on the final order.  I think the idea is to sort based on the X- 
Y ratio, rather than the raw values.

Any algorithm will work and the result become the sort value, such as

get the rect of fleld k
get (item 2 of IT) div (item 1 of IT) after fieldList
put comma & k after fieldList
put cr after fieldList

It depends on the authors desired logic.

Jim Ault
Las Vegas






More information about the use-livecode mailing list