Skip to main content
Known Participant
July 26, 2008
Question

Simple Dynamic Evaluation Question

  • July 26, 2008
  • 2 replies
  • 350 views
Can someone show me how to reproduce this with a CFLOOP? I can't seem to get past the dynamic variable naming. Thanks!
    This topic has been closed for replies.

    2 replies

    Inspiring
    July 26, 2008
    LionelR wrote:
    > Can someone show me how to reproduce this with a CFLOOP?

    Just think through what you need to do in general terms first. It seems as if you need take three variables:

    colorID1, colorID2, colorID3

    .. and split each one into two parts:

    colorID1_1, colorID1_2
    colorID2_1, colorID2_2
    colorID3_1, colorID3_2

    So roughly speaking you want to

    1. Loop three times
    2. Within each loop, split the current variable into two parts

    The rest is just becomes a matter of constructing the dynamic variable names using array notation.

    <cfloop from="1" to="3" index="suffix">
    <cfset variables["colorid"& suffix &"_1"] = ListGetAt(variables["colorid"& suffix],1)>
    <cfset variables["colorid"& suffix &"_2"] = ListGetAt(variables["colorid"& suffix], 2)>
    </cfloop>

    <cfdump var="#variables#">
    Inspiring
    July 26, 2008
    deleted, it was wrong