Skip to main content
Inspiring
Jul 5, 2021 10:26 PM UTC
Answered

cffunction possible error in output?

Consider this function which returns whatever its input is::

<cffunction name="FredTest" output="yes" access="public" returnType="string">
<cfargument name="lsVarIn" type="string" required="true"/>
<cfreturn lsVarIn />
</cffunction>

I test the function using: ABC#FredTest("DEF")#GHI

I expected to see the output as ABCDEFGHI but instead got ABC DEFGHI.  I can't figure out why.  Everytime I try to use cffunction to return a string CF adds a space in front of the output.  Any idea why?  Thanks.

    This topic is closed to new replies. Start a new post to keep the conversation going.
    BKBK
    BKBKCorrect answer
    Community Expert
    Jul 6, 2021 8:46 AM UTC

    It is not an error. The extra space is just the empty space from the body of the function. 

     

    Solution:

    Set output to "no" in the function definition. That is, output="no".

    That is the recommended setting, unless in cases where you have good reason to set it to "yes". 

    2 replies

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    Jul 6, 2021 8:46 AM UTC

    It is not an error. The extra space is just the empty space from the body of the function. 

     

    Solution:

    Set output to "no" in the function definition. That is, output="no".

    That is the recommended setting, unless in cases where you have good reason to set it to "yes". 

    Translate
    Inspiring
    Jul 6, 2021 10:30 AM UTC

    BKBK, Thank you so much.  You saved me a lot of work trying to find a work around.  Thanks again!

    Translate