Or why not just return the query seeing as how it's already basically what you 
want.....

________________________________
From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Darin Kohles
Sent: Thursday, September 09, 2010 1:08 PM
To: discussion@acfug.org
Subject: Re: [ACFUG Discuss] newbie question: storing an array variable into a 
variable whose data type is not specified

Since you mentioned C++, I'm assuming you have some OOP. Why aren't you storing 
each person as an object?

<cfloop ...>
...
  <cfset peoplearray[mycounter] = StructNew() >
  <cfset peoplearray[mycounter].empID = printPeople.empID>
   ...

On Thu, Sep 9, 2010 at 8:35 AM, 
<axunderw...@ups.com<mailto:axunderw...@ups.com>> wrote:
A potential problem with your code is not scoping the variable in the function 
- it's very possible that outside your function you have another variable named 
result that could be conflicting with your function.

<cffunction name="myfunction" access="remote" returntype="struct">

       <cfargument name="form_data" type="struct">

<!---  The variable to be returned by the function is "result"  --->
<cfset var result = StructNew() />
<cfset var person = "" />
<cfset result['dept_name'] = "some dept"
<cfset result['dept_num'] = "some dept number"
Try putting that in there and see if it helps.



________________________________
From: ad...@acfug.org<mailto:ad...@acfug.org> 
[mailto:ad...@acfug.org<mailto:ad...@acfug.org>] On Behalf Of Clarke Bishop
Sent: Thursday, September 09, 2010 11:24 AM
To: discussion@acfug.org<mailto:discussion@acfug.org>
Subject: RE: [ACFUG Discuss] newbie question: storing an array variable into a 
variable whose data type is not specified

I think <cfset foo['sauce'] = []/> started working with CF8, so this could 
still be a problem with an earlier version of ColdFusion.

Also, Chris, just so you know, you can put multiple lines inside a <cfscript> 
block. It usually looks more like:
<cfscript>
   Line 1 of code;
   Line 2 of code;
   Line 3 of code
...


</cfscript>

Easier to read in my opinion!

   Clarke

From: ad...@acfug.org<mailto:ad...@acfug.org> 
[mailto:ad...@acfug.org<mailto:ad...@acfug.org>] On Behalf Of Steve Ross
Sent: Thursday, September 09, 2010 10:03 AM
To: discussion@acfug.org<mailto:discussion@acfug.org>
Subject: Re: [ACFUG Discuss] newbie question: storing an array variable into a 
variable whose data type is not specified

actually that should work fine...

because this works:

<cfset foo['sauce'] = []/>
<cfdump var="#foo#">

On Thu, Sep 9, 2010 at 9:56 AM, 
<viswanathan.jayara...@atl.frb.org<mailto:viswanathan.jayara...@atl.frb.org>> 
wrote:
I think you have to first declare

<cfset result = StructNew()>

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

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



Jay Jayaraman
Central Billing Services
Financial Management and Planning
(404) 498-8453 (W)
(404) 273-7131 (C)



From:        Chris H <h_chris...@yahoo.com<mailto:h_chris...@yahoo.com>>
To:        discussion@acfug.org<mailto:discussion@acfug.org>
Date:        09/09/2010 09:51 AM
Subject:        [ACFUG Discuss] newbie question: storing an array variable into 
a variable whose data type is not specified
Sent by:        ad...@acfug.org<mailto:ad...@acfug.org>
________________________________



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 FusionLink<http://www.fusionlink.com/>
-------------------------------------------------------------


-------------------------------------------------------------
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 FusionLink<http://www.fusionlink.com>
-------------------------------------------------------------



--
Steve Ross
web application & interface developer
http://blog.stevensross.com
[mobile] (912) 344-8113
[ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ]

-------------------------------------------------------------
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 FusionLink<http://www.fusionlink.com>
-------------------------------------------------------------

-------------------------------------------------------------
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 FusionLink<http://www.fusionlink.com>
-------------------------------------------------------------



--
Darin Kohles
Adobe Certified Developer



-------------------------------------------------------------

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