ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 28th, 2004, 05:12 PM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
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!!

Reply With Quote
  #2  
Old August 28th, 2004, 07:44 PM
kaasu kaasu is offline
Web Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 58 kaasu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 1 m 4 sec
Reputation Power: 5
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>

Reply With Quote
  #3  
Old August 28th, 2004, 11:53 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
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

Reply With Quote
  #4  
Old August 29th, 2004, 01:11 PM
babygodzilla babygodzilla is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 197 babygodzilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 28 m 35 sec
Reputation Power: 5
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > dynamic structure name, and some syntax questions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway