|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
dynamic structure name, and some syntax questions
first of all i cant remember coldfusion code on top of my head. ill try but maybe ill just write some pseudo-code, or something relatively understandable.
ok so say i have an array that's like this: names = array("apple","orange","banana") and i want to use the elements of this array to name a structure, something like Code:
newArray = ArrayNew(1) <cfloop index="i" from="1" to="#arrayLen(names)#"> (or whatever the syntax is for length of array) newArray.#names[#i#]# = names[#i#] </cfloop> ok well that syntax is of course terribly wrong, but i hope you see what i am trying to do, which is to dynamically name my structures. is that possible? another syntax question. i have a form with element like Form["Section_"&#number#], where #number# is a number that a loop's index. now i want to check if this element exist, something like Code:
<cfif IsDefined('Form["Section_"&#number#]']>
</cfif>
obviously this code is completely wrong. so what is the correct way to write that? THANKS!! |
|
#2
|
|||
|
|||
|
I am unable to understand first part of your question that do you want to create an array or structure, the code the you have written is creating an array not a structure.
For second part you can easily do something like this <cfif structkeyexits( form, 'Section_' & number )> Do work here </cfif> |
|
#3
|
|||
|
|||
|
I think what you really mean is that you want to dynamically name your structure keys. You can do this several ways...
<cfset "myStruct.#aKeyName#" = whatever.... <cfset structInsert( myStruct, aKeyName ) /> <cfset myStruct[aKeyName] = whatever...
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
yes! the structure KEY thats what i meant. sorry for being vague. and thanks for answering my questions! ill try these ASAP and see if they work.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > dynamic structure name, and some syntax questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|