I'll post this again in case nobody saw it the first time this is a fully
functional formurl2attributes:

<cfscript>
        if (thisTag.executionMode EQ "start") {
                //Defaults for URL and FORM scopes
                caller.attributes = StructNew();

                if (isDefined("url")) {
                        if (isStruct(url)) {
                                for (itemURLParam in url)
                                        evaluate("caller.attributes.#itemURLParam# = 
url.#itemURLParam#");
                        }
                }

                if (isDefined("form")) {
                        if (isStruct(form)) {
                                for (itemFormParam in form)
                                        evaluate("caller.attributes.#itemFormParam# = 
form.#itemFormParam#");
                        }
                }
        }
</cfscript>


-----Original Message-----
From: BOROVOY Noam [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 11, 2000 9:04 AM
To: Fusebox
Subject: RE: Replacement for formurl2attributes


So to maintain the current order of precedence as in FormURL2Attributes:

<CFSCRIPT>
        if ( Not isDefined("Attributes") OR Not isStruct(Attributes)
                Attributes=StructNew();
        if (isDefined("Form") AND isStruct(Form)
        StructAppend(Attributes, Form, False);
        if (isDefined("URL") AND isStruct(URL)
        StructAppend(Attributes, URL, False);
</CFSCRIPT>

Should be way faster, also allows using CFSCRIPT, another speed bonus.


        ----------
        From:  Michael Dinowitz [SMTP:[EMAIL PROTECTED]]
        Sent:  Sunday, 10 December 2000 20:04
        To:  Fusebox
        Subject:  Replacement for formurl2attributes

        For those who have installed SP2 for CF 4.5.1, you may notice a few
new
        functions. One of them was almost perfectly designed for Fusebox.
This is
        the StructAppend() function
        (http://127.0.0.1/CFIDE/Administrator/docs/451update.htm#1026139).
        What this function does is take 2 structures and appends ALL of the
values
        from one of them onto the other. This sounds very much like what the
        formurl2attributes fuse does. Lets look at some example code that
takes the
        URL and FORM variables and appends them to the Attributes structure.

        <!--- If the Attributes scope is not defined, create it. The only
time it
        will not be defined is when you are not within a custom tag --->
        <CFIF Not IsDefined('Attributes')>
            <CFSET Attributes=StructNew()>
        </CFIF>
        <!--- Append ALL Url variables onto the Attributes structure. This
will
        overwrite variables of the same name. --->
        <CFSET StructAppend(Attributes, Url)>
        <!--- Append ALL Form variables onto the Attributes structure. This
will
        overwrite variables of the same name. --->
        <CFSET StructAppend(Attributes, Form)>

        Now this may not be exactly what is needed in Fusebox, but its
enough to
        show everyone what this new function is, what it does and how to use
it. I
        expect it to become a well loved part of the methodology fast. :)

        Oh, one small note is that if you do not want the StructAppend()
function to
        overwrite a variable in the 'target' function, you just have to add
an
        additional attribute to the function. i.e.

        <!--- Append ALL Form variables onto the Attributes structure. This
will NOT
        overwrite variables of the same name. --->
        <CFSET StructAppend(Attributes, Form,0)>
        Notice the third attribute which has a Boolean value of 0 (or no).
This
        simply says, don't overwrite.

        Michael Dinowitz
        Publisher: Fusion Authority weekly news alert
        (www.fusionauthority.com/alert)
        Listmaster: CF-Talk, CF-Jobs, Spectra-Talk, Jrun-Talk, etc.
        (www.houseoffusion.com)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        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