The zip file in the previous post contains 4 custom tags and their editors.
The STRLIB.cfm file would be copied to your custom tag directory under
CFUSION\CustomTags.  All of the tag editors are the same with the exception
that they each output a tag by there own name, but all of these tags have a
common attribute which is the SCOPE attribute. Here is a break down of what
the custom tag does.

1.
First check to see if the SCOPE attribute is present in the call to the
custom tag.
--------------------------------
<CFIF NOT IsDefined( 'Attributes.SCOPE' )>
<HR>
<H4>Missing Attribute</H4>

You need to specify a value for the [ <B>SCOPE</B> ] attribute. This
attribute is required for the <B>CF_STRLIB</B> tag.
<HR>
<CFABORT>
<CFELSE>
 <CFSET scopeVar = Attributes.SCOPE>
</CFIF>
--------------------------------

2.
Setting that scopeVar variable will allow me to load the function into a
scope when the tag is finished running them.

3.
using concatenation to create a string that can be used in the isDefined()
function any function in your custom tag would be chosen to see if it exists
in the scope chosen by the user.

--------------------------------------
<CFSET evalString = scopeVar & '.IsEmail'>
<!---
 Check to see if the scope named above contains the isEmail function.
 If it does then do not run the rest of the tag, otherwise build
 the function library and assign it to the requested scope.
--->
<CFIF NOT IsDefined("#evalString#")>
--------------------------------------

4.
If the above returns true or does not find the IsEmail function in the scope
attribute, for example if the scope attribute was session and the tag had
already been run once, the value session.email would already be present and
the condition above would return false. If the condition above returns false
then the rest of the custom tag stops running and returns you to the rest of
your page processing.

5.
Given the above is true the next thing to do is run all of the function
inside a set of cfscript tags.
---------------------------
<CFSCRIPT>
function isEmail(){
    return "testing with this string of text";
}
</CFSCRIPT>
---------------------------

6.
This next loop is where the assignment will take place. First set up a list
of scope names to be searched.

------------------------------------------------------
scopelist = "server,application,session";
<CFLOOP INDEX="func" LIST="IsEmail,other,Functions,In,The,Library"
DELIMITERS=",">

6a.
Check to see if the scope chosen by the user is found in the scopelist

--------------------------------
 <CFIF ListContains(scopelist,Lcase(trim(scopeVar)))>
------------------------------

6b.
If it is, Use cflock to prevent multiple users from writing to the same
variable name at the same time.

-------------------------------
  <CFLOCK TIMEOUT="10" THROWONTIMEOUT="No" TYPE="EXCLUSIVE"
SCOPE="#scopeVar#">
  <CFSET Evaluate(scopeVar & "." & func & "=" & func)>
  </CFLOCK>
------------------------------

6c.
Other wise in the case of a request scope or local variable just assign the
function name to a variable of it's own name

---------------------------
 <CFELSE>
  <CFSET Evaluate(scopeVar & "." & func & "=" & func)>
 </CFIF>
</CFLOOP>
-----------------------------

After the custom tag runs it will not need to run again unless you chose the
request scope in which case it is not persistent and the tag will run again
and again for each new page request..

7.
To access your function in the session scope for example you would refer to
it as:

------------------
<CFOUTPUT>
#session.IsEmail('[EMAIL PROTECTED]')#
</cfoutput>

Ever request after the tag has already run will come right from the session
structure and as a result your function call will run just like it was a
native function call like Len() or ListContains(). That's pretty much it in
a nut shell.


----- Original Message -----
From: "Bryan LaPlante" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, June 06, 2001 9:11 AM
Subject: Re: CF 5 Eval


| Ok let me get the sleep out of my eye's.
|
| I am going to keep responding to my own post in an effort to keep the
| progression of the responses cleaner. I don't all my presentations
together
| yet but I will probably present this subject to my cfug in Kansas city
| meeting after next.
|
| Here is what I found about User defined functions.  Raymond Camden and Rob
| Brooks-Bilson are leading a project called Common Function Library Project
| at http://www.cflib.org/.
| They have put together 4 libraries of udf's complete with documentation
and
| examples, very helpful in getting you started with udf's.
|
| The notion of loading a group of functions using cfinclude at the top of
| ever template that requires access to said functions, well I am thinking
| it's too heavy. go download http://www.netwebapps.com/projects/cflp.zip
this
| zip file while I go get my coffee and I will explain what I have done to
| allow you to drop these libraries into you custom tags folder and only
have
| to load them once pre session,application,request or server occurrence,
| which ever you choose.
|
| Bryan
|
| ----- Original Message -----
| From: "Bryan LaPlante" <[EMAIL PROTECTED]>
| To: "CF-Talk" <[EMAIL PROTECTED]>
| Sent: Wednesday, June 06, 2001 1:43 AM
| Subject: CF 5 Eval
|
|
| | Is anyone else evaluating or currently using CF 5? I have got
| | some examples I would like to share with you about getting tons of user
| | defined functions to run in memory instead of having to load them at the
| top
| | of ever page. It is kind of the same effect you would get from caching a
| | query except with a function instead.
| |
| | Anyway before I go into it. Anybody?
| |
| | Bryan LaPlante
| | 816-347-8220
| | [EMAIL PROTECTED]
| | http://www.netwebapps.com
| | Web Development
| |
| |
| |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to