Hi All,

I am a newbie to Coldfusion. My development background is mainly in C/C++ so 
please excuse me if my below question is naive. 

I have a function as below

<cffunction name="myfunction" access="remote" returntype="any">
        <cfargument name="form_data" type="struct">

<!---  The variable to be returned by the function is "result"  --->

<cfset result['dept_name'] = "some dept"
<cfset result['dept_num'] = "some dept number"

<!---  I run a query where I want to find some information about people having  
name "John" and there can be N number of people with the name of John --->


<cfquery dbtype="query" name="printPeople">
    SELECT *
    FROM people
    WHERE peopleName = "John"
</cfquery>

<cfset peoplearray=ArrayNew(1)>

      <cfset myCounter = 0 />
         <cfloop query="printPeople">
            
           <cfset myCounter = myCounter + 1 />
                                                

          <cfscript>         
                  ArrayAppend(peoplearray, #printPeople.empID#);
          </cfscript>

          <cfscript>         
                  ArrayAppend(peoplearray, #printPeople.departmentname#);
          </cfscript>


          <cfscript>         
                  ArrayAppend(peoplearray, #printPeople.departmentID#);
          </cfscript>


          <cfscript>         
                  ArrayAppend(peoplearray, #printPeople.empTitle#);
          </cfscript>

          </cfloop>



                <cfset result['people_info'] = peoplearray <!--- Can this be 
done? --->

                <cfset result['statMsg'] = 'Information successfully 
collected.'>
                <cfset result['status'] = true>

     <cfreturn result>

</cffunction>


The part <cfset result['people_info'] = peoplearray
attempts to store an array variable into a variable whose data type is not 
specified.

Can this be done?

If not, what should I do? Should I define the datatype of "result" variable as 
a 
structure, change the return type
in function signature as a structure from any as a structure variable
can hold string, integer and array variables?

Any suggestions would be appreciated.



      


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to