2 Replies Latest reply on May 8, 2008 8:18 PM by Newsgroup_User

    CFC question

      How do I call a function from another function in the same CFC?

      For example, let's say that I have a CFC called: cart.cfc

      One of the functions in the cfc is: getCartSubTotal, which takes one argument - the cart ID

      Now in the same cart.cfc, I want to have a function called getShipping.

      I'm thinking I should be able to pass it the same cart ID and have it get the cart sub total from the function getCartSubTotal. But how do I call that other function from the new function?

        • 1. Re: CFC question
          Dan Bracuk Level 5
          cfinvoke argumentcollection=arguments

          is a handy piece of code.
          • 2. Re: CFC question
            Level 7
            inside same cfc you can call a function like
            <cfset myvar = functionname(argument1, argument2, ..., argumentN)>
            check out the docs for various ways to pass arguments to a function -
            the above example assumes you pass args to the function in same order
            they appear in the cffunction tag.

            in your case, you can have code like below in your getShipping function:

            <cffunction name="getShipping" access="public">
            <cfargument name="cartid" type="numeric" required="yes">
            <cfset var cartSubTotal = getCartSubTotal(arguments.cartid)>


            Azadi Saryev