CreateObject / var Incompatibility

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

  1. #1

    Default CreateObject / var Incompatibility

    Hi all,

    I am developing some CFCs at the moment and have found that if I try to invoke
    a CFC using the following syntax from within a UDF:

    <cffunction name="etc">
    <cfset var obj = CreateObject ("Component", "componentName") />
    </cffunction>

    I get a 'Missing Argument Name' when executing the function. In order to
    address this issue, I have to create the var and CreateObject apart as follows:

    <cffunction name="etc">
    <cfset var obj = "" />
    <cfset obj = CreateObject ("Component", "componentName") />
    </cffunction>

    Is there something I am doing wrong with my code, or is this behaviour by
    design? I am guessing that the 'var' somehow masks the name of the object from
    the CreateObject function thereby causing the exception, but I am not sure why
    this would be a problem.

    Thanks,
    Darryl

    Darryl A. J. Staflund Guest

  2. Similar Questions and Discussions

    1. firefox incompatibility
      Hi, i have dreamwevaer MX and have made a webpage with a jump menu. the menu works fine in IE but doesnt in firefox. please help? Thanks
    2. #39372 [NEW]: Incompatibility in the PHP API.
      From: cm at cmunt dot demon dot co dot uk Operating system: All PHP version: 5.2.0 PHP Bug Type: *Compile Issues Bug...
    3. server incompatibility
      I recommended Contribute to one of my clients and his web hosting company says: " I do not think Contribute works with our server software. We had...
    4. Incompatibility between Dir 8.5.1. and Win 98 SE ?
      Hi all, I posted another message lately about autolaunch and an issue with Dir 8.5.1. In the meantime, I did the following test : I copied...
    5. INCOMPATIBILITY BETWEEN WIN XP PRO AND LEXMARK Z53
      Since only one person (Tom) responded to the below problem, I decided to reverse the process. I now have the Lexmark Z53 as a local with the WIN ME...
  3. #2

    Default Re: CreateObject / var Incompatibility

    Yeah you can only get away with setting simple values when var(ing) a function
    only variables:-

    ie var myString ="";
    var myBoolean = False;
    var mySturcture = StructNew();

    It is important to var all your function only variables as this will save you
    many hours of head scratching with funny errors when it gets complex.

    Stressed_Simon Guest

  4. #3

    Default Re: CreateObject / var Incompatibility

    i don't believe that's true (at least w/cf7). i create complex java objects
    quite often using vars and i just tested this w/a CFC & it worked as expected.
    perhaps it's something else?



    <cffunction name="aUDF">
    <cfset var z=createObject("component","cfc.i18ncurrency")>
    <cfreturn z.getCurrencySymbol("th_TH")>
    </cffunction>

    <cfdump var="#aUDF()#">

    PaulH 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