>It's interesting how ColdFusion 5.0 seems to allow these functions to be
>saved in a variable scope by referencing the functions as if they were
>variables [scope.func=func]... rather than by referencing them as if they
>were functions [scope.func=func() or scope.func()=func()]...

well wouldn't scope.func=func() set the new var with the return value of the
function?  And scope.func()=func() just doesn't make sense.  But I wonder
whey they didn't allow for us to specify the scope of the function while
declaring the function, that makes more sense to me anyhow?  

something like: 

function server.myFunction(){}

Robert



-----Original Message-----
From: Correa, Orlando (ITSC) [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 13, 2001 3:02 PM
To: CF-Talk
Subject: RE: UDF best practices


Ok... that did it...

It was saving using the 

<CFSET Evaluate(scopeVar & "." & func & "=" & func)>

syntax that did the trick! It sure is nice not having to include the
functions in every single custom tag call...

It's interesting how ColdFusion 5.0 seems to allow these functions to be
saved in a variable scope by referencing the functions as if they were
variables [scope.func=func]... rather than by referencing them as if they
were functions [scope.func=func() or scope.func()=func()]...

I haven't tested yet what happens when you have a local variable named
"mylocal" and a local function named "mylocal"... then set
server.mylocal=mylocal to see if it saves the variable in server scope or
the function in server scope...  

Does anyone know if this "trick" is an official behavior of CF5.0 or
something along the lines of <CFSET "server.#myDynVar#" = value> and
something that is not recommended?

Thanks again!
Orlando




-----Original Message-----
From: Bryan LaPlante [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 09, 2001 1:44 AM
To: CF-Talk
Subject: Re: UDF best practices


I am getting pretty good results with saving my udf's in the session scope.
see the tutorial at
http://www.kcfusion.org/Presentations/cflp.zip

Bryan

----- Original Message -----
From: "Correa, Orlando (ITSC)" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 9:02 PM
Subject: RE: UDF best practices


| If I have a "page" request that calls several templates during the
| request...
|
| For Example:
|
| + application.cfm
|   + myUDF.cfm
| + index.cfm
|   + cfinclude template1.cfm
|   + cfmodule template2.cfm
|
| Should I be able to include myUDF.cfm in the application.cfm file and it
| will be available to index.cfm, template1.cfm, and template2.cfm as
myUDF()?
| Currently I'm getting "Error resolving parameter myUDF" with this setup
when
| calling it from template2.cfm...
|
| If I set server.myUDF = myUDF() in application.cfm I get an "The number of
| arguments passed to a user-defined function cannot be less than the number
| of parameters in its definition. This call to myUDF passes 0 arguments,
but
| 2 parameters are defined.".  So when I pass in two dummy variables
| server.myUDF = myUDF('x','x') I get an "The symbol you have provided
| (server.myUDF) is not the name of a function." in the calling page...
Would
| I need to make the arguments non-required to make this work properly...
|
| In this particular case, I'm running this in a hosted environment, so I
| don't have access to put them in the /cfide/udf/ folder.
|
| Any insight would be appreciated...
|
| Orlando
|
| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
| Sent: Wednesday, August 08, 2001 11:40 AM
| To: CF-Talk
| Subject: RE: UDF best practices
|
|
| You could but what about re-usability outside the application. This is the
| reason for the CFINCLUDE of the UDF. There's nothing stopping you from
just
| putting a UDF in the application.cfm or anywhere on a template. Only
| limitation is that a UDF used as part of a CFINCLUDE must be defined
before
| it's to be used where a page based one can be anywhere on the page (even
| after the UDF call).
|
| At 12:59 PM 8/8/01, you wrote:
| >Couldn't you just put them in the application.cfm for your application??
| >
| >-----Original Message-----
| >From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
| >Sent: 08 August 2001 15:11
| >To: CF-Talk
| >Subject: Re: UDF best practices
| >
| >
| >1. In the admin set the server variables to auto-lock
| >2. run the template containing the UDFs before the application runs or on
| >machine startup.
| >3. Set a CFLOCK with a scope of server
| >4. Set each UDF to a variable in the scope server
| >          <CFSET Server.Test=Test()>
| >5. Call the UDF on any page without using a CFINCLUDE of it
| >          <CFSET name=Server.Test('michael')>
| >
| >This is slightly slower than having the UDFs in a CFINCLUDE that's
included
| >into the page. It's a better practice to do the following:
| >
| >1. Create a small library of UDF's in a template (i.e. all data
validation
| >in one file and all text manipulation in another).
| >2. Save these UDF library templates in the CFIDE/UDF directory.
| >3. Use a <CFINCLUDE Template="/cfide/udf/text.cfm"> in the template you
| >want to use UDFs in.
| >
| >
| >At 08:59 AM 8/8/01, you wrote:
| >
| > >Anyone know what's the best way to set a UDF as a global function for
use
| >by
| > >all tags (custom, includes, etc.)... or does one in fact have to
include
| >the
| > >function code locally in each file that's being called during a page
| > >request?
| > >
| > >Thanks,
| > >Orlando
| > >
| > >
| >
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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