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!

Dynamic array name in cfset

Status
Not open for further replies.

TechDude

Programmer
Jul 20, 2000
62
US
Hi all,

I am trying to create a cfset statement which will set a dynamically named three dimensional array to a query value. the code I have created is:

to create the arrays
<cfloop index=&quot;z&quot; from=&quot;1&quot; to=&quot;#get_pack_size.recordcount#&quot;>
<cfparam name='#Evaluate(DE(&quot;pack_array_&quot; & z))#' default=&quot;&quot;>
<cfset &quot;#Evaluate(de(&quot;pack_array_&quot; & z))#&quot; = ArrayNew(3)>
</cfloop>

to fill them

<cfloop query=&quot;get_pack_size&quot;>
<cfset i = i + 1 >
<cfset curr_array=Evaluate(de('pack_array_'&i))>
<cfset &quot;#evaluate(curr_array&'['&i&'][1][1]')#&quot; = get_pack_size.pack_size>


I get this error message
&quot;The element at position 1 in dimension 3 of object &quot;pack_array_1&quot; cannot be found. That dimension of the object is empty. Please,
modify the index expression.&quot;

it seems like it's trying to set the value of the array as the dynamic variable name rather than the array

ie (the value of pack_array_1[1][1][1]) = get_pack_size.pack_size
rather than
pack_array_1[1][1][1]= get_pack_size.pack_size

any ideas?

Chris Sorel
chris@exnihilo.com
Remember, If you continue to do what you have always done,

you will continue to get what you have always gotten.
 
evaluate(&quot;your_var&quot;) gives you the VALUE of the var, or it seems you're using it to get the NAME of the var (especially in the first part)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top