Array Coolness

Bob Sneidar bobs at twft.com
Mon Mar 2 15:24:05 EST 2009


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!

BTW wouldn't it be great if the new Table Object in the upcoming Rev  
4.0 would accept arrays?

Bob Sneidar
IT Manager
Logos Management
Calvary Chapel CM




More information about the Use-livecode mailing list