Ooh. I was hoping for a simple "yes" ;)

Dealing with structs, especially where variable names are dynamic, is
certainly where I get into the most trouble.

But thanks for the help clearing up my question.


On Sep 2, 3:52 pm, "Barry Beattie" <[EMAIL PROTECTED]> wrote:
> where it gets tricky is struct's (the key names) and queries
>
> <cfset keyOne = "One" />
> <cfset ans = myStruct[keyOne] />
>
> which is the same as
> <cfset ans = myStruct.one />
>
> NOTE: you don't need to go
> <cfset ans = myStruct[#keyOne#] />
> since "keyOne" is a variable and the evaluation is done by the struct
>
> BUT you do need to do this
>
> <cfset ans2 = myStruct2["keyName#keyOne#"] />
> because you need to evaluate the "keyOne" variable as part of a string
> to get the key name
> which in that case would evaluate as
> <cfset ans2 = myStruct2["keyNameOne"] />
> or
> <cfset ans2 = myStruct2.keyNameOne />
>
> NOTE: you cannot do
> <cfset ans2 = myStruct2.keyName#keyOne# />
> illegal syntax. you have to use the [ ] way of writing struct keys if
> the key name needs to be determined.
>
> queries are actually struct's of arrays (fieldnames by rows) so the
> same rules apply. you can quite happily write queries as
>
> <cfset myValue = myQuery[fieldname][rowNumber] />
>
> hope this helps
> barry.b
>
> On Tue, Sep 2, 2008 at 3:40 PM, Taco Fleur <[EMAIL PROTECTED]> wrote:
> > Hi,
>
> > That's incorrect, you'd use ## for example if you need to evaluate a
> > variable in a string, like so
>
> > <cfset myVar = "Some text #variables.myVariable# more text" >
>
> > Following does not need ## around a variable
>
> > <cfset myVar = variables.myVariable >
>
> > Passing them into a function does not require pound signs, but passing them
> > into tags does.
>
> > On 9/2/08, nedlud <[EMAIL PROTECTED]> wrote:
>
> >> Hi all,
>
> >> I've been in my current job for just over a year, which means I've
> >> been using coldfusion for just over a year, and I'm still learning how
> >> to use it.
>
> >> One thing that I keep tripping over is how to handle variables. I'm
> >> forever forgetting the goofy ## bits around them.
>
> >> But it just occurred to me that is (or might be) a simple way for me
> >> to remember.
>
> >> ## goes around variables passed by value.
>
> >> Variables passed by reference have no ##.
>
> >> Is this correct? Or am I just going to confuse myself more by thinking
> >> this way?
>
> > --
> > Try advertising on the new Australian Business Directory
> >www.clickfind.com.au
> > blog:http://australiansearchengine.wordpress.com/
> > Web Designers >http://www.web-designers-australia.com
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to