combine behavior
Jan Schenkel
janschenkel at yahoo.com
Mon Nov 21 14:07:02 EST 2005
--- Harvey Toyama <harvey.toyama at qlogic.com> wrote:
> Hi,
>
> I'm using the split and combine to manipulate
> database records. I notice
> that the documentation says that the order of the
> elements is based on
> an internal order. I require a known order for the
> INSERT and UPDATE
> commands to line up correctly. How can I know the
> order in which my
> elements will recombine from an array? It would seem
> ideal if I could
> set the index to be numeric and to use a binary
> sort.
>
> Any suggestions?
>
> -- Harvey
>
Hi Harvey,
You are correct: combine will place them in an
internal order (which happens to be the hash-value of
the keys of the array).
There are two options: either you roll your own
combine command, or you use the sort command after
combining the array, to get it in the order you want.
Option 1:
--
put the keys of tDataArray into tKeys
sort tKeys numeric ## or some other sort
repeat for each line tKey in tKeys
put tkey & return after tSortedData
end repeat
delete char -1 of tSortedData ## remove trailing
return
--
Option 2:
--
combine tDataArray using return and tab
sort tDaatArray numeric by item 1 of each
--
Of course, you'll have to adapt the above a bit to
suit the structure of the data in your array.
Hope this helped,
Jan Schenkel.
Quartam - Tools for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
More information about the use-livecode
mailing list