wow :( , ok thanks so much, this gave me a good learning process on
the usage of structures, arrays, thanks for your time and above all,
your patience!
I'll go finish the polling plugin and post it on line.

On Oct 28, 1:54 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
> you're missing a right square bracket.
>
> should be
> <cfif len(stprops_pollingdata['answer' & i])>
>
> On Oct 28, 8:26 am, Marco van den Oever <[EMAIL PROTECTED]>
> wrote:
>
> > Ok awesome, but...:
>
> > 13:22:37.037 - Template Exception - in C:\Inetpub\wwwroot\farcry\core
> > \packages\rules\rules.cfc : line 133
> > Invalid CFML construct found on line 73 at column 43.
>
> > And on line 73 is:
>
> > <cfif len(stprops_pollingdata['answer' & i)>
>
> > If i use a plain:
>
> > <cfif len(stprops_pollingdata.answer1)>
>
> > it works, that is also why i don't understand my problem.....
>
> > On Oct 28, 11:49 am, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > You're probably making it more complicated than it needs to be.  Use
> > > an array instead of individual structs.
>
> > > <cfset answers = arrayNew(1) />
> > > <cfloop from="1" to="10" index="i">
> > > <cfif len(stprops_pollingdata['answer' & i)> <!--- dynamically
> > > requested --->
> > > <cfset temp = {} />
> > > <cfset temp.dsn = application.dsn />
> > > <cfset temp.conditions = {} />
> > > <cfset temp.conditions['answer' & i] = 1 /> <!--- dynamically set --->
> > > <cfset temp.conditions.pollingobjectid = stobj.pollingobjectid />
> > > <cfset arrayAppend(answers,temp) />
> > > </cfif>
> > > </cfloop>
> > > <!--- now each element in the answers array contains the
> > > argumentCollection you want to pass to your getMultipleByQuery call ---
>
> > > <cfset sums = arrayNew(1) />
> > > <cfloop array="#answers#" index="answer">
> > > <cfset
> > > arrayAppend(sums,obj.getMultipleByQuery(argumentCollection=answer) />
> > > </cfloop>
>
> > > <!--- now you have another array "sums" which has all your queries ---
>
> > > <!--- for instance, if you wanted to get the sum for answer one you
> > > would request sums[1] --->
> > > <!--- you can see them here --->
>
> > > <cfdump var="#answers#" />
> > > <cfdump var="#sums#" />
>
> > > On Oct 27, 9:46 am, Marco van den Oever <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > This is the code i use, where the number is 1 it should be dynamic, i
> > > > have problems replacing the 1 in the (answer1) in the
> > > > (argumentCollection=stprops_answer1) and
> > > > {answer1='1',pollingobjectid='#stobj.pollingobjectid#'} parts with a
> > > > dynamic value:
>
> > > > <cfif len(stprops_pollingdata.answer1)>
> > > > <cfset stprops_answer1 = {} />
> > > > <cfset stprops_answer1.dsn = application.dsn />
> > > > <cfset stprops_answer1.conditions =
> > > > {answer1='1',pollingobjectid='#stobj.pollingobjectid#'} />
> > > > <cfset answer1_sum =
> > > > obj.getMultipleByQuery(argumentCollection=stprops_answer1) />
> > > > <cfelse>
> > > > <cfset answer1_sum.recordcount = 0>
> > > > </cfif>
>
> > > > and
>
> > > > <cfif len(stprops_pollingdata.answer1)>
> > > > <cfchartdata item="#stprops_pollingdata.answer1#
> > > > (#answer1_sum.recordcount#)" value="#answer1_sum.recordcount#">
> > > > </cfif>
>
> > > > On Oct 27, 2:24 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > > > so you want the conditions struct to have multiple keys
> > > > > answer1,answer2,answer3,etc and pollingobjectid
>
> > > > > <!--- create a struct to hold the arguments you will eventually pass
> > > > > in --->
> > > > > <cfset args = {} />
> > > > > <cfset args.conditions = {} />
> > > > > <cfset args.conditions.pollingobjectid = stobj.pollingobjectid />
> > > > > <cfset args.dsn = application.dsn />
>
> > > > > <!--- now do your loop --->
> > > > > <cfloop from="1" to="3" index="i">
>
> > > > > <!--- now i assume you are doing some logic to determine if answer & i
> > > > > should equal 1 or whatever --->
> > > > > <cfif something is True>
> > > > > <cfset args.conditions['answer' & i] = 1 />
> > > > > </cfif>
>
> > > > > </cfloop>
> > > > > <!--- now args contains the conditions and dsn values, conditions is a
> > > > > struct w/ a number of keys (answer1,2,3, etc so on and pollingobjectid
> > > > > --->
> > > > > <cfset result = obj.getMultipleByQuery(argumentCollection=args) />
>
> > > > > Hope this helps.
>
> > > > > On Oct 27, 8:43 am, Marco van den Oever <[EMAIL PROTECTED]>
> > > > > wrote:
>
> > > > > > Ok, what i want to do, and to use your example about the first code
> > > > > > piece:
>
> > > > > > i want to give the struct with 2 keys (answer1 and pollingobjectid) 
> > > > > > a
> > > > > > i value in the 1 of the answer1 part, so in the loop i get:
>
> > > > > > (answer1 and pollingobjectid)
> > > > > > (answer2 and pollingobjectid)
> > > > > > (answer3 and pollingobjectid)
>
> > > > > > etc
>
> > > > > > On Oct 27, 1:03 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > > > > > hmm.  Not sure what you are asking.
>
> > > > > > > In your first piece of code if i equals 3 after that code runs you
> > > > > > > will have a variable called variables.stprops.answer3.conditions 
> > > > > > > and
> > > > > > > it will equal a struct with 2 keys (answer1 and pollingobjectid).
>
> > > > > > > In your second piece of code you will have a variable called
> > > > > > > variables.answer3_sum and it will be a query.
>
> > > > > > > As long as you are in a loop and the value of i changes, you will 
> > > > > > > have
> > > > > > > variables created dynamically.
>
> > > > > > > In order to call getMultipleByQuery your argumentCollection struct
> > > > > > > must have the dsn key and the conditions key.
>
> > > > > > > On Oct 25, 2:59 pm, Marco van den Oever <[EMAIL PROTECTED]>
> > > > > > > wrote:
>
> > > > > > > > Still don't know how to change the code below to also set the 
> > > > > > > > answer1
> > > > > > > > to something like answer & i, the answer1 needs to be dynamic
> > > > > > > > (answer1 / answer2 / answer 3 etc), is it possible? :
>
> > > > > > > > <cfset variables.stprops['answer' & i].conditions =
> > > > > > > > {answer1='1',pollingobjectid=stobj.pollingobjectid} />
>
> > > > > > > > and
>
> > > > > > > > <cfset variables['answer' & i & '_sum'] =
> > > > > > > > obj.getMultipleByQuery(argumentCollection=stprops.answer1) />
>
> > > > > > > > Thanks!
>
> > > > > > > > On Oct 24, 11:13 pm, Marco van den Oever <[EMAIL PROTECTED]>
> > > > > > > > wrote:
>
> > > > > > > > > Wow what a support :) Ok i now begin to see the structure of 
> > > > > > > > > the
> > > > > > > > > structure, only thing i still not understand is how to set 
> > > > > > > > > the answer1
> > > > > > > > > in:
>
> > > > > > > > > <cfset variables.stprops['answer' & i].conditions =
> > > > > > > > > {answer1='1',pollingobjectid=stobj.pollingobjectid} />
>
> > > > > > > > > <cfset variables['answer' & i & '_sum'] =
> > > > > > > > > obj.getMultipleByQuery(argumentCollection=stprops.answer1) />
>
> > > > > > > > > to something as answer & i, as i can't cfset a struct or 
> > > > > > > > > output a
> > > > > > > > > variable in that area, as i experience
>
> > > > > > > > > On Oct 24, 9:00 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > If I am reading correctly you want to do this (i added CF 
> > > > > > > > > > comments
> > > > > > > > > > explaining myself):
>
> > > > > > > > > > <cfloop index="i" from="1" to="6">
>
> > > > > > > > > > <cfif stprops_polling["answer" & i] GT 0> <!--- you dont 
> > > > > > > > > > need the ##
> > > > > > > > > > and quotes around i --->
>
> > > > > > > > > > <cfset variables.stprops['answer' & i] = {} /> <!--- this 
> > > > > > > > > > is fine --->
> > > > > > > > > >  <!--- you are setting .dsn in the key again.  you to set 
> > > > > > > > > > it as a
> > > > > > > > > > struct.  do this: --->
> > > > > > > > > > <cfset variables.stprops['answer' & i].dsn = 
> > > > > > > > > > application.dsn /> <!---
> > > > > > > > > > move .dsn outside --->
> > > > > > > > > > <cfset variables.stprops['answer' & i].conditions =
> > > > > > > > > > {answer1='1',pollingobjectid=stobj.pollingobjectid} /> 
> > > > > > > > > > <!--- same
> > > > > > > > > > things here, move .conditions out, and no need for ## and 
> > > > > > > > > > quotes --->
> > > > > > > > > > <cfset variables['answer' & i & '_sum'] =
> > > > > > > > > > obj.getMultipleByQuery(argumentCollection=stprops.answer1) 
> > > > > > > > > > /> <!---
> > > > > > > > > > this will result in variables.answer1_sum and 
> > > > > > > > > > variables.answer2_sum,
> > > > > > > > > > etc, as queries is this what you want? its fine if you do 
> > > > > > > > > > but I am
> > > > > > > > > > just checking.  If you want to do answer1.sum or 
> > > > > > > > > > answer2.sum this will
> > > > > > > > > > not work. --->
>
> > > > > > > > > > <cfelse>
>
> > > > > > > > > > <cfset variables['answer' & i & '_sum'].recordcount = 0> 
> > > > > > > > > > <!--- again,
> > > > > > > > > > setting a struct with the explicit key will set it as the 
> > > > > > > > > > key, move
> > > > > > > > > > record count outside --->
>
> > > > > > > > > > </cfif>
>
> > > > > > > > > > </cfloop>
>
> > > > > > > > > > Remember that whatever is within the brackets will be the 
> > > > > > > > > > KEY.  If you
> > > > > > > > > > want nested structures you need to use either another set 
> > > > > > > > > > of brackets
>
> > > > > > > > > > <cfset variables['structkey']['anotherstructkey'] = 
> > > > > > > > > > 'something' />
> > > > > > > > > > OR dot notation
>
> > > > > > > > > > <cfset variables.structkey.anotherstructkey = 'something' />
>
> > > > > > > > > > Perhaps explained better by:
>
> > > > > > > > > > <cfset test = 'SOMEVALUE' />
> > > > > > > > > > <cfset variables['structKey_' & test].anotherstructkey = 
> > > > > > > > > > 'something' /
>
> > > > > > > > > > This will result in a struct called variables with a key 
> > > > > > > > > > called
> > > > > > > > > > 'structKey_SOMEVALUE' which is a struct with a key called
> > > > > > > > > > 'anotherstructkey'0
>
> > > > > > > > > > But, If you do
>
> > > > > > > > > > <cfset variables['structkey_' & test & '.anotherstructkey] =
> > > > > > > > > > 'something' />
> > > > > > > > > > this results in one struct called variables with a key 
> > > > > > > > > > called
> > > > > > > > > > 'structkey_SOMEVALUE.anotherstructkey'
>
> > > > > > > > > > You see?  The dot in the second example does not create 
> > > > > > > > > > another
> > > > > > > > > > struct.  Its just another character in the key.
>
> > > > > > > > > > Hope this helps
>
> > > > > > > > > > Sean
>
> > > > > > > > > > Sean
>
> > > > > > > > > > On Oct 24, 2:49 pm, Marco van den Oever <[EMAIL PROTECTED]>
> > > > > > > > > > wrote:
>
> > > > > > > > > > > ahh ok so i was setting a structure named variables, 
> > > > > > > > > > > great this solved
> > > > > > > > > > > the problem
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to