Hey Joe:
First off, really been enjoying your blog postings on the OO stuff.
keep it up :)
Now...you've piqued my curiousity re: array of CFCs. I'm still
grasping CFCs (conceptually...why/how/where/when to use them
('correctly')), so I'm curious as to how you'd use them in this
setting.
Each CFC would exist only to store information (test number/answers,
in this case)? Or is there some sort of additional functionality that
you'd add that I'm just too myopic to see?
Thx!
Charlie
On Fri, 10 Dec 2004 15:28:05 -0500, Joe Rinehart <[EMAIL PROTECTED]> wrote:
> This will get number of questions in each test (note: if you're pre
> MX, wrap the second arrayLen() in evaluate()).
>
> <cfoutput>
> <cfloop from="1" to="#arrayLen(QstnKey)#" index="i">
> Questions in #QstnKey[i][1][1]# = #arrayLen(QstnKey[i]) - 1#<br />
> </cfloop>
> </cfoutput>
>
> I think this is a really difficult way of going about doing it, and
> Charlie's right, an array of structs would be better. An array of
> CFCs would be even more ideal.
>
> For the array of structs, I'd do this:
>
> <cfscript>
> QstnKey = ArrayNew(1);
> QstnKey[1] = StructNew();
> QstnKey[1].Name = "Test1";
> QstnKey[1].Questions = ArrayNew(1);
> QstnKey[1].Questions[1] = StructNew();
> QstnKey[1].Questions[1].Question = "What do you like about food?";
> QstnKey[1].Questions[1].Answers = ArrayNew(1);
> QstnKey[1].Questions[1].Answers[1] = "a. choice 1";
> QstnKey[1].Questions[1].Answers[2] = "a. choice 2";
>
> // And so on...
> </cfscript>
>
> -joe
>
> On Fri, 10 Dec 2004 13:16:20 -0700, Charlie Griefer
>
>
> <[EMAIL PROTECTED]> wrote:
> > in looking at your original code...arrayLen(QstnKey[1])-1 should do it
> > (the -1 because one of the elements in the array is identifying it as
> > "Test1")
> >
> > i still think the array of structs is cleaner tho :)
> >
> >
> > On Fri, 10 Dec 2004 15:08:50 -0400, Joy Holman <[EMAIL PROTECTED]> wrote:
> > > I got the answer using my original code.
> > > Today my question is:
> > > Using that original code, how can I dynamically determine how many
> > > questions are in Test1? The answer would be "2".
> > >
> > >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - RUWebby
http://www.ruwebby.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187092
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54