Board index » delphi » OLE Automation / Variant Array

OLE Automation / Variant Array

I'm having trouble calling a method of an Automation controller that
requires two arrays of three doubles (which represent 3D floating
point coordinates).

The only docs I have are for Visual Basic, which has
an example for calling the method that goes like this:

Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double

startPoint(0) = 0#
startPoint(1) = 0#
startPoint(2) = 0#
endPoint(0) = 30#
endPoint(1) = 20#
endPoint(2) = 0#

MyOLEObject.DrawLine(startPoint, endPoint)

What do I use in Delphi to call the .DrawLine method?  
I've tried CreateVarArray([0..2], varDouble), and that
is giving me a type mismatch error at runtime.

 

Re:OLE Automation / Variant Array


Tony,

Try to define your variany array using

v := varArrayCreate([0 .. 2], varVariant);

Ron.

On 5 Apr 1997 09:10:54 GMT, "Tony Tanzillo"

Quote
<tony.tanzi...@worldnet.att.net> wrote:
>I'm having trouble calling a method of an Automation controller that
>requires two arrays of three doubles (which represent 3D floating
>point coordinates).

>The only docs I have are for Visual Basic, which has
>an example for calling the method that goes like this:

>Dim startPoint(0 To 2) As Double
>Dim endPoint(0 To 2) As Double

>startPoint(0) = 0#
>startPoint(1) = 0#
>startPoint(2) = 0#
>endPoint(0) = 30#
>endPoint(1) = 20#
>endPoint(2) = 0#

>MyOLEObject.DrawLine(startPoint, endPoint)

>What do I use in Delphi to call the .DrawLine method?  
>I've tried CreateVarArray([0..2], varDouble), and that
>is giving me a type mismatch error at runtime.

Re:OLE Automation / Variant Array


Ron - Thanks for the suggestion, but this is not the
proper syntax for varArrayCreate(). You can't use [from..to],
you must use [from, to] to specify the array bounds.

Ron Loewy <rlo...@transport.com> wrote in article
<3347b295.8757...@news.teleport.com>...

Quote
> Tony,

> Try to define your variany array using

> v := varArrayCreate([0 .. 2], varVariant);

> Ron.

Other Threads