Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Variable Names

Guest
May 22, 2008 May 22, 2008
Okay, I just need to figure out how to make dynamic variable names. In this case, I have a loop, and inside the loop I need to create a new array for every iteration of the loop. Something like

<cfloop from="0" to="10" index="i">
<cfset LoopArray#i# = Some Value>
</cfloop>

But that doesn't work. How can you make dynamic variable named? I think it's probably something to do with evaluate or DE, but I don't know how to use them, and the livedocs make no sense to me. Thanks!
TOPICS
Getting started
391
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , May 22, 2008 May 22, 2008
See attached sample.
Translate
LEGEND ,
May 22, 2008 May 22, 2008
Maybe you are just forgetting your cfoutput tag.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 22, 2008 May 22, 2008
See attached sample.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 22, 2008 May 22, 2008
Thank you both for your replied, I did manage to find a solution (the same one posted by JR "Bob" Dobbs). Pretty much just looks like...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2008 May 22, 2008
LATEST
On Thu, 22 May 2008 17:14:42 +0000 (UTC), kenji776 wrote:

> Thank you both for your replied, I did manage to find a solution (the same one
> posted by JR "Bob" Dobbs). Pretty much just looks like...
>
>
> <cfloop from="1" to="3" index="i">
> <cfset LinkResults["#i#"][1] = "Player 1's Move ID">
> <cfset LinkResults["#i#"][2] = "Player 2's Move ID">
> <cfset LinkResults["#i#"][3] = "Damage to player 1">
> <cfset LinkResults["#i#"][4] = "Damage to player 2">
> </cfloop>

From your values, you don't want a two-dimensional array (which although
you're actually building LinkResults as a struct, with the sequential
numeric keys, it's basically an array), you want an array of structs, eg:

LinkResults .player1.moveId
LinkResults
.player1.damage


What is "i" actually counting through? IE: from 1-3 things... which are...
what?

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources