Cffunction & cfreturn

First, has anyone used BlogCFC? this is dealing with it.
I have put parts of the pods and main content into iframes.
I now need every link to escape & target the top.
I have a problem with this code it seems...
quote:
<cfoutput><a href="#application.blog.makeLink(id)#"
target="_top">#title#</a><br></cfoutput>
And then in the blog.cfc file I find....
quote:
<cffunction name="makeLink" access="public"
returnType="string" output="false"
hint="Generates links for an entry.">
<cfargument name="entryid" type="uuid"
required="true">
<cfset var q = "">
<cfset var realdate = "">
<cfquery name="q" datasource="#instance.dsn#">
select posted, alias
from tblblogentries
where id = <cfqueryparam cfsqltype="cf_sql_varchar"
value="#arguments.entryid#" maxlength="35">
</cfquery>
<cfif q.alias is not "">
<cfset realdate = dateAdd("h", instance.offset,
q.posted)>
<cfreturn
"#instance.blogURL#/#year(realdate)#/#month(realdate)#/#day(realdate)#/#q.alias#">
<cfelse>
<cfreturn
"#instance.blogURL#?mode=entry&entry=#arguments.entryid#">
</cfif>
</cffunction>
Does anyone see from this why target="_top" does not work?
And am I missing the actual creation of makeLink?
seems like the cffunction just is getting the query for it.
I don't deal with cffunctions.

Both are correct and will work, but cffunction has some
advantages. The biggest one is the cfargument tag which gives you
more control over the datatypes coming in. You could code all those
in cfscript, but it's now unnecessary.

Similar Messages

  • CFFunction CFReturn Strings Chopping Results?

    I have a routine that I can run straight up and it will return a list (pipe-delimited) of 1278 results.
    I put it in a function in the same program and I get 1278 results.
    I put it in a function in its own CFC and I get 279 results.
    Anyone ever experienced something like this?  I'm sure I'm screwing up somewhere, but this is quite odd. May have to switch to structure or something to test it in another way.
    ColdFusion 8 on Windows server 2003.
    RLS

    Yep, egg on the face.  Because this routine had to go to an external API to retrieve results and because that API would only return 500 results at a time, I had to loop through it. Part of my loop included calling another internal function to parse an XML. That internal routine and this one shared a variable, the crucial variable returned with cfreturn.  
    Oh, well. Let that be a reminder for anyone who stumbles onto this problem/answer on the internet. Declare your local variables!  http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_29.ht ml, see "Function local variables"
    Thanks again for replying, Dan.

  • Calling CFM from CFC

    Greetings to all
    I not enough work with ColdFusion.
    My question: How I can receive function parametres in *.CFM file  from a *.CFC component?
    OR
    How I can calling functions in CFM from Flex Application?
    For example:
    In CFM:
    <cffunction>
    <cfreturn HelloVariable>
    </cffunction>
    How I can recieve HelloVariable in my Flex Application?
    Sorry for my English

    In your cfc, add a cfinclude to the cfm file and then you have access to the function.

  • Don't understand cffunction and cfcomponent

    I am trying to alter Forta's ajax related select tutorial to fit my needs.  I am having trouble understanding the details of this .cfc though.
    <cfcomponent output="false">
        <!--- Get array of media types --->
        <cffunction name="get_states" access="remote" returnType="array">
            <cfset data="">
            <cfset result=ArrayNew(2)>
            <cfset i=0>
            <!--- Get data --->
            <cfquery name="data" datasource="mydsn">
            SELECT id,states
            FROM state
            </cfquery>
            <!--- Convert results to array --->
            <cfloop index="i" from="1" to="#data.RecordCount#">
                <cfset result[i][1]=data.id[i]>
                <cfset result[i][2]=data.state[i]>
            </cfloop>
            <cfreturn result>
        </cffunction>
        <!--- Get art by media type --->
        <cffunction name="get_waters" access="remote" returnType="array">
            <cfargument name="location" type="string" required="true" default="">
            <!--- Define variables --->
            <cfset var data="">
            <cfset var result=ArrayNew(2)>
            <cfset var i=0>
            <!--- Get data --->
            <cfquery name="data" datasource="mydsn">
            SELECT id,name
            FROM waters
            WHERE bow_state = '#arguments.location#'
            </cfquery>
            <!--- Convert results to array --->
            <cfloop index="i" from="1" to="#data.RecordCount#">
                <cfset result[i][1]=data.id[i]>
                <cfset result[i][2]=data.name[i]>
            </cfloop>
            <!--- And return it --->
            <cfreturn result>
        </cffunction>
    </cfcomponent>
    When I put '#arguments.id#' into the second query, I get results.  However, I'd like to query by the name instead, so I am trying location.  I don't fully understand so I am hacking around with this a bit but I'd like to 1 - get results by name instead of id and 2 - understand the arguments variable so I really know what is going on.
    Thanks!

    Sorry, didn't see this before I posted.
    But I think my suggestion was in keeping with the example.  If you need to select on "state", then make the "state" column of your first query to be the first value in the array that you return:
    <!--- Get data --->
    <cfquery name="data" datasource="mydsn">
         SELECT id,states
         FROM state
    </cfquery>
    <!--- Convert results to array --->
    <cfloop index="i" from="1" to="#data.RecordCount#">
         <cfset result[i][1]=data.state[i]>
         <cfset result[i][2]=data.state[i]>
    </cfloop>
    This will make your select look something like this in the rendered HTML:
    <select id="states" name="whatever...">
         <option value="Alabama">Alabama</option>
         <option value="Alaska">Alaska</option>
    </select>
    So then, on your second, dependent select, you'd specify the binding like so (just like you did, really):
    <cfselect name="waters" bind="cfc:_ffc_cfc_select_jump.get_waters({states})" bindonload="false"></cfselect>
    However, now, because the value of the "states" select options are state names, rather than ids, you should now be able to use the argument in your query based on state names:
    <!--- Get art by media type --->
    <cffunction name="get_waters" access="remote" returnType="array">
         <cfargument name="location" type="string" required="true" default="">
         <!--- Define variables --->
         <cfset var data="">
         <cfset var result=ArrayNew(2)>
         <cfset var i=0>
         <!--- Get data --->
         <cfquery name="data" datasource="mydsn">
            SELECT id,name
            FROM waters
            WHERE bow_state = <cfqueryparam value="#arguments.location#" cfsqltype="varchar" /> <!---Be sure to queryparam!!!--->
         </cfquery>
         <!--- Convert results to array --->
         <cfloop index="i" from="1" to="#data.RecordCount#">
              <cfset result[i][1]=data.id[i]>
              <cfset result[i][2]=data.name[i]>
         </cfloop>
         <!--- And return it --->
         <cfreturn result>
    </cffunction>

  • Cffunction returntype question

    I've got a function (below) in a CFC that executes a stored
    procedure. The procedure has 2 input parameters and a single output
    parameter. I want to cfoutput the value of the output parameter in
    the procedure. The procedure does it's job in CF if I don't return
    the output parameter. I keep having problems with the
    returnvariable type. I've output returntypes of query in the past
    without any problem, but never a single calculated value. The value
    being output by the procedure is a long integer.
    <!--- FUNCTION --->
    <cffunction name="myFunctTest" hint="ProcedureTest"
    returntype="??????">
    <cftry>
    <cfstoredproc procedure="myProc" username='#this.user#'
    password='#this.pass#' datasource='#this.dSource#'>
    <cfprocparam type="Out" cfsqltype="cf_sql_integer"
    variable="OutputID"><!--- Output variable I want to return
    --->
    <cfprocparam type="In" cfsqltype="CF_SQL_INTEGER"
    value='#this.par1#' dbvarname="myPar1">
    <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR"
    value='#this.par2#'dbvarname="myPar2">
    </cfstoredproc>
    <cfcatch type="any">
    <cfreturn "Error in Function...">
    </cfcatch>
    </cftry>
    <cfreturn ??????>
    </cffunction>
    <!--- FUNCTION CALL --->
    <cfinvoke component="cfc.myCFC" method="myFunctTest"
    returnvariable="??????">
    <cfinvokeargument name="user" value="#myUser#">
    <cfinvokeargument name="pass" value="#MyPass#">
    <cfinvokeargument name="dSource" value="#myDSource#">
    <cfinvokeargument name="par1" value="#Form.MyPar1#">
    <cfinvokeargument name="par2" value="#Form.MyPar2#">
    </cfinvoke>
    Thanks in advance
    Roy.

    Combine,
    Are your stored procedure parameters defined in the same
    order you are using them in your CFSTOREDPROC tag? Bear in mind
    that the dbvarname attribute is ignored in CF6+.

  • What is it about CFFUNCTION that slows things down???

    I have some code that imports the contents of an Excel
    spreadsheet into my database, during the import process I also do a
    fair amount of data massaging. When I run this code straight from a
    URL it completes in about 90 seconds. When I encapsulate the exact
    same code into a CFC function and call it from my Flex application
    the run time jumps to around 10 minutes. Is there something about
    calling a CFC function from within Flex that I am missing here? The
    only differences in the code are a few passed in variables (which
    are hard coded in the URL version) and the CFFunction tags. The
    differences are trivial so I don't see how they could be accounting
    for the extra time.
    Any thoughts on why the CFC runs so much slower than the
    CFM??? Oh... I am running CF 7.02 and my client will be on that
    platform for the foreseeable future.
    Have an Ordinary Day...
    KomputerMan ~|:-)

    I think it is something to do with how the end of the
    function processes. I am able to watch the records get wrote into
    my database table. From the time the last record gets wrote to the
    time the end of the function is processed is about 19 seconds for
    500 records. That time goes up when more records are processed too.
    Here is the code at the end of my loop that processes the data
    prior to the end of the function. When the /CFLOOP is reached is
    when the last record is wrote to the table.
    <CFSILENT>
    <!--- bunch of code to import a spreadsheet and put it
    into a temporary database table so the data can be further
    manipulated. This is then followed by a bunch of code to do
    summations, groupings, create referential integrity, etc… and
    then put the clean data into a good data table and the bad data
    into a bad data table. --->
    <CFTRANSACTION>
    <cftry>
    <CFLOOP QUERY="GetData">
    <cftransaction action = "commit"/>
    </CFLOOP>
    <cfcatch type="database">
    <cfthrow message="function = ADD records, MyFlag =
    #MyFlag# #cfcatch.Message# #cfcatch.Detail#">
    </cfcatch>
    </cftry>
    </CFTRANSACTION>
    <!--- here is where I start my stop watch when the record
    count in my table quits incrementing --->
    </CFSILENT>
    <CFSET MyReturnString = GoodCnt & ',' & BadCnt1
    & ',' & BadCnt2 & ',' & BadCnt3>
    <CFRETURN MyReturnString>
    </CFFUNCTION>
    I have been playing with adding a CFTRANSACTION into the code
    to see if that helps or hurts. So far it has not made a difference.
    Bottom line is after the data is processed the function is not
    returning to Flex in a timely manner.
    Have an Ordinary Day...
    KomputerMan ~|:-)

  • Cffunction valitation error

    Hi,
    I have a form where I  fill a customer-no. into an input field and get the customer name using databinding.
    This works fine, but when I put non-numeric values into customer-no I get following error:
    Error invoking CFC customer.cfc : The CUST_ID argument passed to the getcustomer function is not of type numeric. [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
    The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
    Here is my code:
    The form:
    <cfinput type="text" name="customer_no" style="width:140;background-color:yellow" maxlength="10"  validate="integer" validateat="onblur"   message="Customer No. format is integer">
    <cfinput type="text" name="customer_name" style="width:170" maxlength="200" bind="cfc:customer.getcustomer({customer_no})" readonly="yes">
    customer.cfc:
    <cfcomponent >
    <cffunction name="getcustomer" access="remote" returntype="string" output="yes"  >
        <cfargument name="cust_id"   type="numeric"  required="true" >
                     <cfset  r_customer = "">
             <cfquery name = "select_customer" dataSource = "x">
            SELECT name
            FROM customer
            WHERE id =  <cfqueryparam   cfsqltype="cf_sql_numeric" value="#arguments.cust_id#" >
            </cfquery>
    <cfreturn r_customer>
    </cffunction>
    </cfcomponent>

    biene22 wrote:
    The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
    That is a trick question! The attribute bind="cfc:customer.getcustomer({customer_no})" implies that the function will run automatically, whether or not customer_no is numeric.

  • Cffunction error

    The argument TEAM passed to function SearchRes() is not of type numeric.
    If the component name is specified as a type of this argument, the reason for this error might be that a definition file for such component cannot be found or is not accessible.
    The error occurred in C:\Inetpub\wwwroot\search.cfc: line 4
    2 :
    3 :      <cffunction name="SearchRes" access="public" returntype="query">
    4 :        <cfargument name="DSN" type="string" required="yes">
    5 :     <cfargument name="Role" type="string" required="no">
    6 :     <cfargument name="Team" type="numeric" required="no">
    Please look at the above error...any help app...
    code ------------------------->
    <cfcomponent hint="This cfc does search...">
    <cffunction name="SearchRes" access="public" returntype="query">
       <cfargument name="DSN" type="string" required="yes">
        <cfargument name="Role" type="string" required="no">
        <cfargument name="Team" type="numeric" required="no">
        <cfargument name="Level" type="numeric" required="no">
        <cfargument name="zone" type="numeric" required="no">
        <cfargument name="Dept" type="numeric" required="no">
        <cfargument name="location" type="numeric" required="no">
        <cfargument name="csgid" type="string" required="no">
        <cfargument name="status" type="string" required="no">
        <cfargument name="filter" type="string" required="no">
        <cfargument name="bosseid" type="string" required="no">
           <cfdump var="#arguments#">    
          <cfquery datasource="#arguments.DSN#" name="SearchRes">
            Select
              r.First_name,
              r.Last_name,
              r.EID,
              r.tech_id,
              r.title,
              r.hire_date,
              r.rehire_date,
              l.location,
              d.department
            from
              OPS$RMS.REF_resource r,
              OPS$RMS.Ref_department d,
              OPS$RMS.REF_Location l
            where
              r.location_code = l.location_code
              And r.department_code = d.department_code
              <cfif arguments.role neq "">
               And r.role_code = '#arguments.role#'
              </cfif>
              <cfif arguments.Team neq "">
               And r.team_code = #arguments.team#
              </cfif>
              <cfif arguments.level neq "">
               And r.level_code = #arguments.level#
              </cfif>
              <cfif arguments.zone neq "">
               --And r.zone_code = #arguments.zone#
              </cfif>
              <cfif arguments.dept neq "">
               And r.department_code = #arguments.dept#
              </cfif>
              <cfif arguments.location neq "">
               And r.location_code = #arguments.location#
              </cfif>
              <cfif arguments.csgid neq "">
               And r.csg_operator_id like '#arguments.csgid#%'
              </cfif>
              <cfif arguments.status neq "">
               And r.status = '#arguments.status#'
              </cfif>
              <cfif arguments.filter neq "">
                And
                r.EID = '#arguments.filter#%'
                OR r.First_name like '#arguments.filter#%'
                OR r.last_name like '#arguments.filter#%'
                OR r.tech_id like '#arguments.filter#%'
              </cfif>
              <cfif arguments.bosseid neq "">
               And r.boss_id = '#arguments.bosseid#%'
              </cfif>
          </cfquery>  
          <cfreturn SearchRes>
    </cffunction>
    </cfcomponent>

    craigkaminsky wrote:
    Might not be an issue but, while your Team variable can be null, the cfargument tag types the variable as a numeric value (as opposed to any or whatever). Depending on what you're supplying this could be a source of the error.
    As mentioned we would have to see the code.  But that could well be the problem.  There is really no concept of a "null" form field.  If you are passing in the values of text fields, empy fields will be treated as an empty string "".  Since an empty string is not numeric, it would cause exactly the error you are describing.
    <!--- simulate an empty form field ---->
    <cfset form.someField = "" />
    <cfoutput>#test(form.someField)#</cfoutput>
    <cffunction name="test" returntype="string">
        <cfargument name="someValue" type="numeric" />
        <cfreturn "okay"/>
    </cffunction>

  • Cffunction - Accepting and Returning PDFs in memory

    Hello,
    This is something that I should probably know by now in my CF career, but up until now I have never thought/had to do this type of thing.
    I have defined a couple functions that I would like to handle accepting, manipulating, and returning PDFs in memory. What data types should I be using for accepting and returning the PDF in memory between functions?  I would prefer to stay away from "any" if possible, but let me know if that is the only choice.
    <cffunction name="AddMeUhWaddaMak" returntype="any" access="public" output="no">
            <cfargument name="src" type="any" required="yes">
            <cfargument name="name" type="string" required="no">
                   <cfpdf action="addWatermark"
                            source="#arguments.src#"
                            name="#arguments.name#"
                             ...>
                         <cfreturn arguments.name>
    </cffunction>

    Thanks again for the advice.  I was doing a little tinkering around with isPDFObject() just to see how it works and came to another question. See below..
    <cfdocument format="pdf" name="test2">
    test
    </cfdocument>
    <cfdump var="#isPDFObject(test2)#"><cfabort>
    The result says "NO", even though when I dump out "test2" it shows up as binary.

  • Cffunction returns space

    Hi,
    I am using coldfusionmx6 and created function.while it calling in xml it giving space.How to delete space?
    <cffunction name="datereplaceformat" returntype="string">
      <cfargument default="" name="datechange" required="No">
       <cfargument default="" name="formatchange" required="No">
    <CFSET var SDATE=reREPLACE(datechange,"#formatchange#"," ","all")>
    <CFSET var rspace=reREPLACE(SDATE," ","","all")>
    <cfreturn rspace>
    </cffunction>
    sample xml:
    <cfoutput>
    <va4>
    <datepost>#trim(datereplaceformat(variables.NotPostedTransDate,"/"))#</datepost>
    </va4>
    </cfoutput>
    In posting page it showing as
    <va4>
    <datepost>
    10302010
    </datepost>
    </va4>
    Advance Thanks

    Adding the output="no" property to the the <cffunction...> tag so that ColdFusion does not include any whitespace from the function may help.
    You may also want to consider some of ColdFusion's other whitespace management features.  <cfsilent>...</cfsilent>  <cfsetting enableCFoutputOnly="Yes"> being a couple of the most utilized.

  • CFFUNCTION not working

    I am using CF5.0, but <CFFUNCTION> tag seems not
    working.
    Below is my codes,
    - Codes -
    <cffunction name="funcWelcomeMsg" returntype="string">
    <cfparam name="strUsername" type="string">
    <cfreturn strUrername>
    </cffunction>
    - Error -
    ColdFusion cannot determine how to process the tag
    <CFFUNCTION>. The tag name may be misspelled.
    If you are using tags whose names begin with CF but are not
    ColdFusion tags you should contact Allaire Support.

    Hi,
    Try doing it using <cfscript>
    <cfscript>
    function myFunction() {
    </cfscript>
    I do not think you can do it that way in CF 5. Is it possible
    for you to upgrade to at least ColdFusion MX? If so then your code
    would work I presume.
    -Westside

  • CFFUNCTION question

    I am trying to run a function like:
    <cfoutput>#F_name#</cfoutput>
    <CFFUNCTION NAME="F_name">
    ... generates some tables and reports ...
    </cffunction>
    Instead of the tables, I have a coded string of characters.
    Am I missing something here ?
    Should the function be in CF component ?
    Thanks for help !

    If your function generates output, then the below would work.
    <cfoutput>#F_name()#</cfoutput>
    But I'm guessing you're not generating output and just doing
    calculations, you need to return the value using something like
    <cffunction name="F_name">
    <cfset a = 1>
    <cfset b = 2>
    <cfreturn a + b>
    </cffunction>

  • CFFUNCTION returntype error

    "The value returned from the addRequirement function is not
    of type query" is what I get when I execute the below function.
    This works fine in 7, but in 8 I get that error. Any ideas?
    <CFFUNCTION NAME="addItem" output="false"
    returntype="query">
    <CFARGUMENT NAME="userid" TYPE="numeric"
    REQUIRED="true">
    <CFARGUMENT NAME="title" TYPE="string"
    REQUIRED="true">
    <cfset var addRequirement = "">
    <CFQUERY NAME="addItem" datasource="#variables.dsn#">
    INSERT INTO test(userID,title)
    VALUES (#ARGUMENTS.userID#,'#arguments.title#')
    </CFQUERY>
    <cfreturn addItem>
    </CFFUNCTION>

    In addition to the insert not returning a result set, you
    have your var declared as 'addRequirement'
    but your query name and return value are 'addItem'
    If it were me, I'd set the return type to boolean, then set a
    var result = 'FALSE'. Wrap the insert query in a CFTRY and if it's
    sucessful, set result = 'TRUE' and then return result

  • Cfreturn variable is not recognized when outputing content

    I have a page that i wish to display total invoices paid to a particular contractor. This Page is Runnign CF9. I'm using a CFC page to write my queries and a action page to display the output via a search box from a search page. Whenever i input the invoice id, coldfusion throws the error: Variable RECENT_INVOICE is undefined"  Am i missing something? my syntax is written below:
    <!---CFC PAGE--->
    <cfcomponent>
    <cffunction name="getinvoice" access="public" returntype="query">
    <cfquery name="recent_invoice" datasource="w9">
    SELECT invoice.*, project.*, bid.*, CONCAT(w9.w9fname,' ', w9.w9lname,'  ', w9.w9businessname) AS Contractor, w9.*
    FROM invoice, project, bid, w9
    WHERE invid = #form.invid#
    AND INVOICE.invcontractor = W9.w9ID
    AND INVOICE.invproject = PROJECT.proID
    AND INVOICE.invproject = BID.bidproject
    AND INVOICE.invcontractor = BID.bidcontractor
    </cfquery>
    <cfreturn recent_invoice>
        </cffunction>
    </cfcomponent>
    <!---Display page that show the invoked query--->
    <cfinvoke
      component="invoice.componets.test"
      method="getinvoice"
      returnvariable="recent_invoice">
    <!--- CFC Query --->
    </cfinvoke>
    <!---OUTPUT Items Below--->
    <cfoutput>#recent_invoice.invdate# - #recent_invoice.invjob1# - #recent_invoice.invamt1#</cfoutput>

    Looks like you are referencing a form field in your query; form.invid.  You are not submitting a form, you are calling a cfc so you probably want to add an argument to your function and pass the value when you call it.  Change like so:
    <!---CFC PAGE--->
    <cfcomponent>
    <cffunction name="getinvoice" access="public" returntype="query">
    <cfargument name="invid" type="numeric" required="true" />
    <cfquery name="recent_invoice" datasource="w9">
    SELECT invoice.*, project.*, bid.*, CONCAT(w9.w9fname,' ', w9.w9lname,'  ', w9.w9businessname) AS Contractor, w9.*
    FROM invoice, project, bid, w9
    WHERE invid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.invid#" />
    AND INVOICE.invcontractor = W9.w9ID
    AND INVOICE.invproject = PROJECT.proID
    AND INVOICE.invproject = BID.bidproject
    AND INVOICE.invcontractor = BID.bidcontractor
    </cfquery>
    <cfreturn recent_invoice>
    </cffunction>
    </cfcomponent>
    <!---Display page that show the invoked query--->
    <cfinvoke
      component="invoice.componets.test"
      method="getinvoice"
      invid="#yourInvoiceNumber#"
      returnvariable="recent_invoice">
    <!--- CFC Query --->
    </cfinvoke>

  • Why setting var in CFFUNCTION causes error

    As far as my knowledge goes, the BEST practise when setting
    local variable inside a CFFUNCTION is to use the word "var" in
    front of the variable name, for example: <CFSET var
    myVariable="whatever">
    I'm doing it now and all I get is an error message saying:
    Error invoking CFC name_of_cfc:local variable myVariable on
    line 60 must be grouped at the top of the function body!
    I'm using CF8 and I need to use cfswitch within the
    cffunction, so when I do <cfcase value="SomeValue"><cfset
    var myVariable="TheValue"></cfcase> etc I got that error.
    When I tested with just CFSET var MyVariable="TheVariable"
    with no cfswitch/cfcase I still get that error
    when I took out the word "var" from cfset, I have no error, I
    put these variables directly after my cfarguments. Does anyone know
    why this is happening to me?
    I thought if I don't use the "var" word for my variable set
    within cffunction there will be possibilities when later on setting
    up another variables outside this function and if the name happen
    to be the same, will override each other and causing disaster to my
    application.
    Please help!!

    mega_L wrote:
    > As far as my knowledge goes, the BEST practise when
    setting local variable
    > inside a CFFUNCTION is to use the word "var" in front of
    the variable name, for
    > example: <CFSET var myVariable="whatever">
    Yes, this is the best practice to make the variable local to
    the
    function. But you only need to use the var keyword once when
    you define
    the variable. And you must define the local variables with
    the var
    keyword at the very beginning of the function body. The only
    content
    allowed before this happens are the argument definitions,
    i.e. the
    <cfargument ...> tags.
    If you have a variable that you don't need to use, you just
    need to
    define it with a default and|or dummy value in the beginning
    of the
    function. Then you can set it's value appropriately later in
    the
    function when it is required. This is often done with query
    tag return
    variables.
    I.E.
    <cffunction name="myQryFunction"...>
    <cfargument name="someArgument"...>
    <cfset var localQry = "">
    <cfquery name="localQry"...>
    SQL
    </cfquery>
    <cfreturn localQery>
    </cffunction>
    Because of this necessity to define all local variables at
    the beginning
    of the function, a lot of developers use a standard where
    they define a
    local structure. They can then just append new keys and
    values to this
    local structure throughout the function. Personally I don't
    see much
    advantage to doing this, but to each his|her own.
    I.E.
    <cffunction name="myQryFunction"...>
    <cfargument name="someArgument"...>
    <cfset var local = structNew()>
    <cfset local.something = "FooBar">
    <cfreturn local.something>
    </cffunction>

Maybe you are looking for