<--- --------------------------------------------------------------------------------------- ---- Blog Entry: Ask Ben: Converting a Query to an Array Author: Ben Nadel / Kinky Solutions Link: http://www.bennadel.com/index.cfm?dax=blog:124.view Date Posted: Jul 10, 2006 at 8:50 AM ---- --------------------------------------------------------------------------------------- ---> // Define the local scope. var LOCAL = StructNew(); // Get the column names as an array. LOCAL.Columns = ListToArray( ARGUMENTS.Data.ColumnList ); // Create an array that will hold the query equivalent. LOCAL.QueryArray = ArrayNew( 1 ); // Loop over the query. for (LOCAL.RowIndex = 1 ; LOCAL.RowIndex LTE ARGUMENTS.Data.RecordCount ; LOCAL.RowIndex = (LOCAL.RowIndex + 1)){ // Create a row structure. LOCAL.Row = StructNew(); // Loop over the columns in this row. for (LOCAL.ColumnIndex = 1 ; LOCAL.ColumnIndex LTE ArrayLen( LOCAL.Columns ) ; LOCAL.ColumnIndex = (LOCAL.ColumnIndex + 1)){ // Get a reference to the query column. LOCAL.ColumnName = LOCAL.Columns[ LOCAL.ColumnIndex ]; // Store the query cell value into the struct by key. LOCAL.Row[ LOCAL.ColumnName ] = ARGUMENTS.Data[ LOCAL.ColumnName ][ LOCAL.RowIndex ]; } // Add the structure to the query array. ArrayAppend( LOCAL.QueryArray, LOCAL.Row ); } // Return the array equivalent. return( LOCAL.QueryArray );