Bug(?) CFMX return value functions

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Bug(?) CFMX return value functions

    Hi,

    I think I have found some sort of bug when you directly output the returned
    value in a function. ColdFusion seems to insert a whitespace before the
    returned value to a string.
    Here's an example:
    The first image is broken because the image adds a whitespace between
    "159x120/" and the image name. Setting it to a variable first seems to work.
    Any idea's?



    <cffunction name="fnReturnImage">
    <cfreturn "159x120_box_cfmx7">
    </cffunction>

    <cfoutput>
    Direct output: <br>
    <img
    src="http://www.macromedia.com/images/shared/product_boxes/159x120/#fnReturnImag
    e()#.gif">
    <cfset imageSrc = fnReturnImage()>
    Set to a var first: <br>
    <img
    src="http://www.macromedia.com/images/shared/product_boxes/159x120/#imageSrc#.gi
    f">
    </cfoutput>

    JorritJ Guest

  2. Similar Questions and Discussions

    1. PL/pgSQL functions and RETURN NEXT
      Here's an example that I butchered to cut it down to size that should illustrate what you need to do (basically use a LOOP construct) CREATE TYPE...
    2. Functions that return RECORD type
      Hi I come from a MS-SQL background and am trying to figure out what is wrong with the function below:...
    3. functions return by reference question
      If I want a function to return by reference, I do this? function & myCoolFunction() { $queryObject = new queryObject(); return $queryObject; }...
    4. [PHP] functions/methods and what they should return
      You want to break off things into as many functions and components as possible. The idea is that if you want to change the way tables are...
    5. functions/methods and what they should return
      Hi people. I'm working on a large application right now (complete ecom store) and I'd like to get some feedback on something. Each product...
  3. #2

    Default Re: Bug(?) CFMX return value functions

    It's well documented (on these and other forums, anyhow ;-), and "expected
    behaviour" (that's not to say it's not *crap* expected behaviour).

    Add output="false" to your <cffunction> tag.

    --

    Adam
    Adam Cameron Guest

  4. #3

    Default Re: Bug(?) CFMX return value functions

    Put output="false" in ths cffunction tag and it will fix it!



    <cffunction name="fnReturnImage" output="false">
    <cfreturn "159x120_box_cfmx7">
    </cffunction>

    <cfoutput>
    Direct output: <br>
    <img
    src="http://www.macromedia.com/images/shared/product_boxes/159x120/#fnReturnImag
    e()#.gif">
    <cfset imageSrc = fnReturnImage()>
    Set to a var first: <br>
    <img
    src="http://www.macromedia.com/images/shared/product_boxes/159x120/#imageSrc#.gi
    f">
    </cfoutput>

    Stressed_Simon Guest

  5. #4

    Default Re: Bug(?) CFMX return value functions

    Argh! Yes it sounds logical if you think of it.
    Why didn't I think of this! :(

    The folowing code works as well (without the output="no" option). So it is
    expected behavour!



    <cffunction name="fnReturnImage3"><cfreturn "159x120_box_cfmx7"></cffunction>

    JorritJ Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139