Skip to main content
Inspiring
October 16, 2008
Question

How to accomplish for more than 1 array??

  • October 16, 2008
  • 1 reply
  • 671 views
I have this code:

<cfset classList=arraynew(2)>
<cfset classListLoop="A,B,C,D,E,U">
<cfset classLoopCount=1>
<cfloop list="#classListLoop#" delimiters="," index="i">
<cfset classList[#classLoopCount#][1]=#i#>
<!--- send to udf to count each rating occurance and assign
to variable --->
<cfinvoke component="components.ov_rating" method="rating"
returnvariable="result">
<cfinvokeargument name="tid" value="#url.tid#">
<cfinvokeargument name="dbfield" value="e_foil_rating">
<cfinvokeargument name="rating" value="#i#">
</cfinvoke>
<cfset classList[#classLoopCount#][2]=#result#>
<cfset classLoopCount=classLoopCount+1>
</cfloop>


<!--- Loop through all registered fencers to get a total count --->
<cfset regTotal=0>
<cfloop from="1" to="6" index="i">
<cfset regAdd=classList[#i#][2]>
<cfset regTotal=regTotal + regAdd>
</cfloop>

<!--- Send array and regTotal to UDF to determine tournament classification
--->
<cfinvoke component="components.class" method="determine" returnvariable="classification">
<cfinvokeargument name="fencers" value="#classList#">
<cfinvokeargument name="fencerNumber" value="#regTotal#">
</cfinvoke>

This works fine for 1 array, but how can I do it for 2 arrays?


    This topic has been closed for replies.

    1 reply

    Inspiring
    October 16, 2008
    >
    > This works fine for 1 array, but how can I do it for 2 arrays?

    You would need to loop over this twice.

    Your system does not allow to do this so easily. You need some
    condition to let your system determine when it is working with one array
    and when it is working with two. Can it ever be more then two?

    I do not know where this code is in relationship to the first block. So
    I do not know if the same condition used there or some values set there
    to trigger the creation of one or two arrays can be used here to
    determine if you need to loop over this block once or twice.

    But as I said in my previous response. This system would be much easier
    if your classList was an array arrays so that it would then know if
    there are one or two or any other number of arrays to process.

    Inspiring
    October 16, 2008
    Hello Ian,

    I haven't worked with array of arrays, or however you put it..... where can
    I find info on how to make that work??

    >> This works fine for 1 array, but how can I do it for 2 arrays?
    >>
    > You would need to loop over this twice.
    >
    > Your system does not allow to do this so easily. You need some
    > condition to let your system determine when it is working with one
    > array and when it is working with two. Can it ever be more then two?
    >
    > I do not know where this code is in relationship to the first block.
    > So I do not know if the same condition used there or some values set
    > there to trigger the creation of one or two arrays can be used here to
    > determine if you need to loop over this block once or twice.
    >
    > But as I said in my previous response. This system would be much
    > easier if your classList was an array arrays so that it would then
    > know if there are one or two or any other number of arrays to process.
    >