1 Reply Latest reply on Mar 13, 2007 3:10 PM by insuractive

    Type casting for properties accessed in COM Object

    Rick
      I have a com object that I need to access which provides my a list of addresses in an Array. The object give me a property that has a count for the number of addresses and then I have a loop that calls the property which contains the address details to get each individual address each time passing to the property the INDEX value on the loop.

      This errors out each time.

      The error I get is
      Error casting an object of type to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.

      It appears the the variable type of the index is not compatible with the property of the component(which is an int).

      IS there some way to type cast the variable used as the index for CFLOOP to that of an INT?
        • 1. Type casting for properties accessed in COM Object
          insuractive Level 3
          You can try to use the JavaCast("int", myValue) function. It works great for Java objects, but I'm not sure how well it will work for COM. Worth a try, I guess.

          In your case it would be something like:

          <cfobject type="COM" context="INPROC" action="create" name="MR" class="DLLNAME">
          <cfloop from="1" to="#AddressCount#" index="i">
          <cfset VDname = mr.vdsname(JavaCast("int", i))>
          <cfset VDaddress = mr.vdsaddress(JavaCast("int", i))#>
          <cfset VDXML = mr.VDSXML(JavaCast("int", i))>
          </cfloop>