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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create an Array

Status
Not open for further replies.

IFELSETHEN

Programmer
May 1, 2002
221
0
0
US
I would like to dynamically create an array …..

This doesn’t work …..
<CFSET aryName = &quot;LOC&quot; & &quot;#j#&quot;>
<CFSET #aryName# = #arrayNew(1)#>
<CFSET #arrayappend(aryName,1)#>

Thanks John
 
That last CFSET is malformed. You can iether CFSET a &quot;temp&quot; variable:

<cfset j=3>
<CFSET aryName = &quot;LOC&quot; & j>
<CFSET aryName=arrayNew(1)>
<CFSET temp=arrayappend(aryName,1)>

<cfoutput>
#aryName[1]#
</cfoutput>

OR use CFSCRIPT

<cfscript>
j=3;
aryName=&quot;LOC&quot; & j;
aryName=arrayNew(1);
arrayappend(aryName,1);
</cfscript>
 
Ok ... this is good. Now I need to append some data to my array....

<CFLOOP index=&quot;j&quot; from=&quot;1&quot; to=&quot;#lCount#&quot;>
<CFIF #aryLocatorName[j]# EQ #array_row2[aj][1]#>
<CFSET temp = ArrayAppend(&quot;LOC&quot; & #j#,array_row3[aj])>
</cfif>
</cfloop>

.... and I get an error saying that &quot;LOC1&quot; needs to be a name of an array. Kinda thought that we did that with the first code. John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top