Makes sense though, as an array is basically a structure.  And structures
are passed by reference.

Btw, Just wanted to add my two cents and say thanks for the list.  Great
resource.

Shawn Grover

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 10, 2001 1:35 PM
To: CF-Talk
Subject: RE: Passing variables in UDF


I was wrong in saying that an array was passed by reference. I just tested 
it out and it is passed by value. I was assuming based on the normal array 
function results that it would be. I hate when things are not 'standard'.

Causes an error
<CFSCRIPT>
         function test(aVar)
         {
                 aVar[1] = "name";
         }
         aVar=ArrayNew(1);
         test(aVar);
         WriteOutPut(aVar[1]);
</CFSCRIPT>

works
<CFSCRIPT>
         function test(aVar)
         {
                 aVar[1] = "name";
                 return aVar;
         }
         aVar=ArrayNew(1);
         aVar=test(aVar);
         WriteOutPut(aVar[1]);
</CFSCRIPT>


At 03:21 PM 9/10/01, you wrote:
>If the var is simple or array, then it is by value. If you pass in a
>struct or a query, then it is by ref.
>
>=======================================================================
>Raymond Camden, Principal Spectra Compliance Engineer for Macromedia
>
>Email    : [EMAIL PROTECTED]
>Yahoo IM : morpheus
>
>"My ally is the Force, and a powerful ally it is." - Yoda
>
> > -----Original Message-----
> > From: Carlisle, Eric [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, September 10, 2001 1:24 PM
> > To: CF-Talk
> > Subject: Passing variables in UDF
> >
> >
> > Are variables passed by reference or by value in CF UDFs?
> >
> >       Thanks,
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to