• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Type casting for properties accessed in COM Object

Explorer ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

233

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation