Bob Sneidar wrote:
Okay, I am now a staunch believer in Rev Arrays. I query every column
in my app's SQL database (SELECT *), but now I need to reorder the
columns, because the Listmagic widget has the capability of displaying
some columns and not others simply by assigning a number to a
property. All columns up to and including that number get displayed,
all others are hidden, ok?
So rather than rearranging my SQL data, I need to rearrange the data
returned from my query instead. What I need is a way to go through all
the columns and "move" every column I don't want displayed to the
"end" of the array. So I decided I would put Rev Arrays to the test
like so:
put theColumns & return & theData into theTableData
split theTableData by column
set the itemdelimiter to tab
put the number of items of theColumns into theColumnCount
set the itemdelimiter to comma
put theTableData[1] into theTableData[theColumnCount + 1]
delete variable theTableData[1]
combine theTableData by column
theColumns is a tab delimited list of the SQL column names, and
theData is a tab delimited list of the SQL data. After running this
script, lo and behold, what was the first column in the array is now
the last! THAT IS AWESOME! Great job Runtime Revolution!
Indeed it is awesome. I too love arrays.
But as a dedicated benchmarker, I'd have to point out that the more simple
set the itemdelimiter to Tab
put item 2 to -1 of theColumns & the itemdelimiter & item 1 of
theColumns &cr into theTableData
repeat for each line L in theData
put item 2 to -1 of L & the itemdelimiter & item 1 of L &cr
after theTableData
end repeat
will do the same thing, but roughly 40% faster (YMMV, since it is very
data dependent).
-- Alex.
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution