Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating Multi-dimensional Arrays?

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Can someone please advice how I can populate a Multi-dimensional array?

I have tried the following as AppendArray (I think!) only refers to 1D Arrays:

<CFSET TEMP = ArrayLen(RESULTS) + 1>
<CFSET RESULTS[1][#TEMP#] = #BAND_1_START#>
<CFSET RESULTS[2][#TEMP#] = #BAND_1_END#>
<CFSET RESULTS[3][#TEMP#] = #BAND1.RecordCount#>

I have looked at others examples where they had similar problems but I am unsure which value refers to the dimension and which refers to the element/row.

I am obtaining the following error when this script is run:

Error Diagnostic Information
An error occurred while evaluating the expression:
RESULTS[1][#TEMP#] = #BAND_3_START#
Error near line 146, column 19.
--------------------------------------------------------------------------------
Cannot set element of indexed object
The element at position 1 of the object cannot be set. May be the object is read-only. The object has elements in positions 1 through 0.
The error is in dimension 1 of object &quot;RESULTS&quot;.

Any help would be appreciated, Thanks
 
Try this:
Code:
<CFOUTPUT QUERY=&quot;myQuery&quot;>
   <CFSET RESULTS[CurrentRow][1] = BAND_1_START>
   <CFSET RESULTS[CurrentRow][2] = BAND_1_END>
   <CFSET RESULTS[CurrentRow][3] = BAND1.RecordCount>
</CFQUERY>

That should give you what you're looking for. Kevin
slanek@ssd.fsi.com
 
I think you might just have your index variables backwards;

<CFSCRIPT>
i = ArrayLen(RESULTS) + 1;
RESULTS
Code:
[
i
Code:
]
Code:
[
1
Code:
]
= BAND_1_START;
RESULTS
Code:
[
i
Code:
]
Code:
[
2
Code:
]
= BAND_1_END;
RESULTS
Code:
[
i
Code:
]
Code:
[
3
Code:
]
= BAND1.RecordCount;
</CFSCRIPT> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top