I would have to play with your code more if this does not
clear it up
for you, but lets start with this simple concept first.
You mentioned "typing the array" several times. ColdFusion is
typeless,
you don't type an array, it is just array. An array of
strings is the
same as an array of integers which is the same as an array of
objects.
So if you had a function something like this.
<cffunction ...>
<cfset theArray = arrayNew()>
<cfloop ...>
<cfset arrayAppend(theArray, newObject)>
</cfloop>
<cfreturn theArray>
</cffunction>
The return type of this array would be type="array". No
matter what
kind of data the array contained.
mwiley63 wrote:
> I just picked up coldfusion about a month ago, so my
coldfusion lingo sucks. I
> have been programming in C++ for over 5 years now and
will be using a lot of
> C++ terminology to help avoid any confusion. I am
writing a cfc function that
> preforms web servicing. This function needs to return an
object/class that is
> defined in another coldfusion function. I can do this
without a problem if I
> only need to return one instance of this object.
However, I cannot seem to
> return an array of this object (I need to return
multiple instances of this
> object, kind of like a query, but for programming
purposes it needs to stay as
> an object).
>
> It seems that the webservicing function hates my return
type. If I try to
> make an array of the object, it does not like array or
the object as the return
> type. However, when I take this function out of the cfc,
and make it a cfm, it
> gets the array of objects just fine. So, I think I am
having issues with the
> return type on the <cffunction> tag. So I came up
with the idea of creating
> another object which will hold an array of the first
object and using the
> second object as the return type. Here is some psuedo
code of the function I
> am working on:
>
> <cffunction name="SelectGames" access="remote"
returntype="ArrayOfGames"
> output="false">
> <!-- arguments --->
> <!--- query --->
> <cfobject component = "myArray" name>
> <cfobject component="games" name="test">
> <cfset counter = 0>
> <cfloop query="getevents">
> <cfset counter = counter + 1>
> <cfset test.Game_id = event_id>
> <cfset test.gameDate = eventdate>
> <cfset test.Starttime = starttime>
> <cfset test.Place = place>
> <cfset test.Level = level>
> <cfset test.Sport = sport>
> <cfset test.Gender = division>
> <cfset test.Opponent = opponent_id>
> <cfset test.Type = type>
> <cfset test.Link = spec_name>
> <cfset myArray.gamesArray[counter] = test>
> </cfloop>
> <cfreturn myArray>
> </cffunction>
>
> It keeps telling me that it does not recognize the
return type.
> Here are examples of the two objects I am using from the
2 dif. cfc files:
> <cfcomponent>
> <cfproperty name="gamesArray" type="array">
> </cfcomponent>
> <cfcomponent>
> <cfproperty name="Game_id" type="numeric">
> <cfproperty name="gameDate" type="date">
> <cfproperty name="Starttime" type="string">
> <cfproperty name="Place" type="string">
> <cfproperty name="Level" type="string">
> <cfproperty name="Sport" type="string">
> <cfproperty name="Gender" type="string">
> <cfproperty name="Opponent" type="string">
> <cfproperty name="Type" type="string">
> <cfproperty name="Link" type="string">
> </cfcomponent>
>
> Feel free to post any questions to clear anything up, I
know this is confusing
> and I probably did a poor job of explaining my problem.
Also, if I throw this
> code into a cfm and try to make an array of games, it
works, this is the code I
> got it to work with:
> <cfset myArray = newArray(1)>
> <cfloop query="getevents">
> <cfset counter = counter + 1>
> <cfset test.Game_id = event_id>
> <cfset test.gameDate = eventdate>
> <cfset test.Starttime = starttime>
> <cfset test.Place = place>
> <cfset test.Level = level>
> <cfset test.Sport = sport>
> <cfset test.Gender = division>
> <cfset test.Opponent = opponent_id>
> <cfset test.Type = type>
> <cfset test.Link = spec_name>
> <cfset myArray[counter] = test>
> </cfloop>
>
> I guess my problem is I do not know how to specify a
type for an array.
>