Ok I think that's where I'm needing to be, because I need the ability to
access the methods in the animal object.  This code loads DATA values into
an array of arrays int the cage, I think??

<cffunction name = loadAnimals returntype=void>
        <cfargument name=incomingArrayofAnimals type=array>
        <cfloop from"1" to "#ArrayLen(incomingArrayOfAnimals#" index="i">
        <cfset arrayAppend(animalArray,
"#arguments.incomingArrayOfAnimals[i]#">
        </cfloop>
</cffunction>

Will this give me the animal methods?
Application.cfm

<cfif not isdefined("Session.myCage")>
<cfset Session.myCage = CreateObject('component','cage')
</cfif>
<cfif not isdefined("Session.myAnimal")>
<cfset Session.myAnimal = CreateObject('component','animal')
</cfif>

<cffunction name = loadAnimals returntype=void>

        <cfargument name=incomingArrayofAnimals type=array>
        <cfloop from"1" to "#ArrayLen(incomingArrayOfAnimals#" index="i">
        <-- Pass the array of DATA into the myAnimal object and build it there -->
        <cfset myAnimal.new(incomingArrayOfAnimals[i])">
        <cfset arrayAppend(animalArray,myAnimal)>
        </cfloop>
</cffunction>

Then, when I wanted to know how much the monkey in the cage, cost,would I
say...

<cfset monkeyCost = Session.myCage.getAnimalCost(query.currentRow)>

In the cage.cfc

        <cffunction name = getAnimalCost>
                <cfargument name = row>
        <cfset cost = animalArray[row].getCost()>
        <cfreturn cost />
        </cffunction>
Jamie


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Monday, October 13, 2003 12:48 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Query Results into objects


yeah...also, a thought...in your cage CFC you could have addAnimal() and
deleteAnmimal().  In your DB calls, or form processing calls, you call
addAnimal to add one animal object to your animalArray.  Prior to this you
actually create an instance of this animal setting its properties and all.
So addAnimal actually requires an instance of the animal cfc, not an array
of animal instances.  Something like this at least.  Some of the CFC Jedi
Masters around here may chime in with a definitive view...???

Doug

>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Behalf Of Adrian Lynch
>Sent: Monday, October 13, 2003 1:40 PM
>To: '[EMAIL PROTECTED]'
>Subject: RE: [CFCDev] Query Results into objects
>
>
>You're using Array Append the wrong way, it creates a new
>element for you to
>store something in. You're trying to add on an array.
>
>Off the top of my head try looping over the input array appending each
>element to the cage array.
>
>Ade
>
>-----Original Message-----
>From: James K Tieman [mailto:[EMAIL PROTECTED]
>Sent: 13 October 2003 18:27
>To: [EMAIL PROTECTED]
>Subject: RE: [CFCDev] Query Results into objects
>
>
>That works perfect...next problem
>I have a cage.cfc and an animal.cfc., now I need to put the
>animals into the
>cage.  On a form someone says get me a list of furry animals
>and cost.  We
>loop thru the result and create an array of objects "certainAnimals =
>ArrayNew(1).  What is the method inside cage.cfc supposed to look like,
>because it doesn't like the line below?
>
><cfset Session.cage.loadAnimals(certainAnimals)>
>
>
><cfcomponent hint "I am a cage">
><cfset cageNumber = "">
><cfset animalArray=ArrayNew(1)>
><cfset totalCostOfCage = "">
>
><cffunction name = loadAnimals returntype=void>
>       <cfargument name=incomingArrayofAnimals type=array>
>       <cfset arrayAppend(animalArray,
>"#arguments.incomingArrayOfAnimals#">
></cffunction
>
>
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Behalf Of Adrian Lynch
>Sent: Monday, October 13, 2003 11:20 AM
>To: '[EMAIL PROTECTED]'
>Subject: RE: [CFCDev] Query Results into objects
>
>
>I'd agree with Doug. An array of objects seems to suit your needs well.
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: 13 October 2003 17:15
>To: [EMAIL PROTECTED]
>Subject: RE: [CFCDev] Query Results into objects
>
>
>I'd use arrays dor this, so you would have an array of objects.
>
>myobjs = ArrayNew(1)
>then
>myobjs[i] = CreateObject("component", "foo").init()
>then this should be doable
>goo = myobjs[3].getAmount()
>
>Doug
>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>Behalf Of James K Tieman
>>Sent: Monday, October 13, 2003 12:07 PM
>>To: [EMAIL PROTECTED]
>>Subject: RE: [CFCDev] Query Results into objects
>>
>>
>>yes, but how do I refer to it later?
>><cfset i = "001">
>><cfset "obj#i#" = CreateObject("", "") does create the object.
>>now, how do I access the object without knowing that it  is
>>now "obj001"?  I
>>can't do this <cfset obj#i#.init()>, but I can, of course, do
>>this <cfset
>>obj001.init()>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>Behalf Of Adrian Lynch
>>Sent: Monday, October 13, 2003 10:52 AM
>>To: '[EMAIL PROTECTED]'
>>Subject: RE: [CFCDev] Query Results into objects
>>
>>
>>Can you still use <cfset "obj#i#" = CreateObject("", "") />?
>>
>>Ade
>>
>>-----Original Message-----
>>From: Adam Wayne Lehman [mailto:[EMAIL PROTECTED]
>>Sent: 13 October 2003 16:16
>>To: [EMAIL PROTECTED]
>>Subject: RE: [CFCDev] Query Results into objects
>>
>>
>>What about:
>>
>>setVariable("obj" & i, createObject("component", "accounts"))
>>
>>Adam Wayne Lehman
>>Web Systems Developer
>>Johns Hopkins Bloomberg School of Public Health
>>Distance Education Division
>>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>>Behalf Of James K Tieman
>>Sent: Monday, October 13, 2003 10:59 AM
>>To: Cfcdev
>>Subject: [CFCDev] Query Results into objects
>>
>>I want to create objects from a query recordset and I don't
>know how to
>>name
>>the objects so I can, for example, obj7.setAmount(obj1.getAmount() *
>>obj4.getAmount()). <c<cfset obj#i# =
>>CreateObject('component','accounts')>
>><cfset obj#i#.init()>  I realize I'm showing my ignrnc, but
>>that's why I
>>asking.
>>
>>Jamie


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to