ahh ok so i was setting a structure named variables, great this solved
the problem and the code looks very neat.
one more question if i may, of course i now also want to update the
other code to use looping instead of static, i really gave this a try
but before i try stuff that just doesn't work, here it is:
p.s. the problem i have i understanding how to:
replace the " {answer1='1' " in <cfset variables.stprops['answer' & i
& '.conditions'] =
{answer1='1',pollingobjectid='#stobj.pollingobjectid#'} />
and how to
replace the " stprops.answer1 " in <cfset variables['answer' & i &
'_sum'] = obj.getMultipleByQuery(argumentCollection=stprops.answer1) /
>
with the index value
<cfloop index="i" from="1" to="6">
<cfif stprops_polling["answer" & "#i#"] GT 0>
<cfset variables.stprops['answer' & i] = {} />
<cfset variables.stprops['answer' & i & '.dsn'] = application.dsn />
<cfset variables.stprops['answer' & i & '.conditions'] =
{answer1='1',pollingobjectid='#stobj.pollingobjectid#'} />
<cfset variables['answer' & i & '_sum'] =
obj.getMultipleByQuery(argumentCollection=stprops.answer1) />
<cfelse>
<cfset variables['answer' & i & '_sum' & '.recordcount'] = 0>
</cfif>
</cfloop>
Thanks again!
On Oct 24, 7:44 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
> Oh. Now I see what you want to do. You want stprops_pollingvote to
> be a structure. So do this
>
> <cfset variables.stprops_pollingvote['answer' & i] = '1' />
>
> the stprops_pollingvote is the structure here. In the previous one,
> variables was the structure and "stprops_pollingvote.answer1" was the
> key.
>
> You want variables.stprops_pollingvote and have "answer1" as the key
>
> Sean
>
> On Oct 24, 9:46 am, Marco van den Oever <[EMAIL PROTECTED]>
> wrote:
>
> > Tomek thanks, when i use evaluate like:
>
> > <cfloop index="i" from="1" to="6">
>
> > <cfif #form[stprops_polling.objectid]# EQ "#i#">
>
> > <cfset evaluate("stprops_pollingvote.answer" & "#i#") = "1">
>
> > </cfif>
>
> > </cfloop>
>
> > i get an error:
>
> > 15:40:31.031 - Template Exception - in C:\Inetpub\wwwroot\farcry\core
> > \packages\rules\rules.cfc : line 133
>
> > Cannot assign a value to a function.
>
> > Sean, also thanks, when i use your suggestion:
>
> > <cfloop index="i" from="1" to="6">
>
> > <cfif #form[stprops_polling.objectid]# EQ "#i#">
>
> > <cfset variables[ "stprops_pollingvote.answer" & i ] = "1">
>
> > </cfif>
>
> > </cfloop>
>
> > the structure not gets the value assigned, when i use this:
>
> > <cfif #form[stprops_polling.objectid]# EQ "1">
> > <cfset stprops_pollingvote.answer1 = "1">
> > <cfelseif #form[stprops_polling.objectid]# EQ "2">
> > <cfset stprops_pollingvote.answer2 = "1">
> > <cfelseif #form[stprops_polling.objectid]# EQ "3">
> > <cfset stprops_pollingvote.answer3 = "1">
> > <cfelseif #form[stprops_polling.objectid]# EQ "4">
> > <cfset stprops_pollingvote.answer4 = "1">
> > <cfelseif #form[stprops_polling.objectid]# EQ "5">
> > <cfset stprops_pollingvote.answer5 = "1">
> > <cfelseif #form[stprops_polling.objectid]# EQ "6">
> > <cfset stprops_pollingvote.answer6 = "1">
> > </cfif>
>
> > it works fine, and although the structure is the same in output, in
> > code view it's of course more neat to have it in a loop.
>
> > So just leave it like this or is it possible to do so in a loop??
>
> > Thanks both!
>
> > On Oct 24, 2:06 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > dont use evaluate. Try:
>
> > > <cfset i = '1' />
> > > <cfset variables[ "stprops_pollingvote.answer" & i ] = "1">
> > > <cfdump var="#variables#" />
>
> > > just worked for me. What is "i" set to?
>
> > > On Oct 23, 9:38 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
>
> > > > i think something like
> > > > <cfset evaluate("stprops_pollingvote.answer" & "#i#") = "1"> might
> > > > work. If
> > > > that doesn't, I think generally you need to use evaluate for something
> > > > like
> > > > that. That's the only way I can think of to get something like that done
> > > > though.
>
> > > > Best,
>
> > > > Tomek
>
> > > > On Thu, Oct 23, 2008 at 8:02 PM, Marco van den Oever <
>
> > > > [EMAIL PROTECTED]> wrote:
>
> > > > > I loop over
>
> > > > > <cfset variables[ "stprops_pollingvote.answer" & "#i#" ] = "1">
>
> > > > > and when the selected form value is equal to the number in the index
> > > > > it sets the above item, so if option 1 was selected then
> > > > > stprops_pollingvote.answer1 is cfset to 1.
>
> > > > > Just read "You cannot use a dynamic variable when you create a
> > > > > structure implicitly." at cfm docs, so that implies you have to work
> > > > > with cfif statements and cfset the structure items static, or is there
> > > > > some other farcry trick available?
>
> > > > > On Oct 24, 1:52 am, Marco van den Oever <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > I want to set up structure items by a loop:
>
> > > > > > <cfset variables[ "stprops_pollingvote.answer" & "#i#" ] = "1">
>
> > > > > > so this will result in:
>
> > > > > > <cfset stprops_pollingvote.answer1 = "1"> ect etc
>
> > > > > > this is however not working, as this is a part of a structure, do i
> > > > > > need it to create otherwise?
>
> > > > > > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"farcry-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/farcry-dev?hl=en
-~----------~----~----~----~------~----~------~--~---