Board index » delphi » problem when calling two method of an automation server

problem when calling two method of an automation server

I want to create a new instance of an automation server application and
use some of the function available, but I always have an exception error

when I call one of this function : getFullMatrix or putFullMatrix

The parameters of the functions in the type librairy are :

FUNCTION GetFullMatrix  (in Interface)

returnType :    HResult
parameters:
                      name : BSTR [in]
                      worskace : BSTR [in]
                      pr : safeArray of double* [in,out]
                      pi : safeArray of double* [in,out]

FUNCTION PutFullMatrix  (in Interface)

returnType :    HResult
parameters:
                      name : BSTR [in]
                      worskace : BSTR [in]
                      pr : safeArray of double [in]
                      pi : safeArray of double [in]

The program look's like this :

var
    FMatlab : Variant;
    pr,pi : Variant
begin
    // work correctly; the application open...
    FMatlab := createOleObject('Matlab.application');
    // work correctly; I execute command in the server
    FMatlab.execute('a=13;');
    // This is one of the way I try to initialise the variable pr and pi

(safeArray)
    pr := varArrayCreate([0,1],varDouble);
    pi := varArrayCreate([0,1],varDouble);
    // Error
    FMatlab.putFullMatrix('myVariable','workspace',pr,pi);
    ...
end;

When I execute the last line I always have this error :
           project1.exe raised exception class EOLESysError with message

'Types non correspondants'
Or this one
           project1.exe raised exception class EOLESysError with message

'Types mismatch'

What can I do?

Thanks for your help...

Vincent Lapointe

 

Re:problem when calling two method of an automation server


Hi Vincent,

Safe arrays are not Ole-Automation compartible
(in your case IDispatch.Invoke() simply doesnt not recognize them as a valid
parameter)

They can not be used with Typelib-based marshalling either..
use Variant  that holds safearray instead of  "raw" safearray pointer

the interface  method declaration should look something like:
 FUNCTION GetFullMatrix  (in Interface)

 returnType :    HResult
 parameters:
                       name : BSTR [in]
                       worskace : BSTR [in]
                         pr: VARIANT*[in, out];
                         pi :VARIANT* [in,out];

The example of usage you provided is valid for this case.

Hope it helps,

Alexander Myachin

Quote
"Vincent Lapointe" <lapointe_vinc...@hotmail.com> wrote in message

news:3A660CF4.90987C71@hotmail.com...
Quote
> I want to create a new instance of an automation server application and
> use some of the function available, but I always have an exception error

> when I call one of this function : getFullMatrix or putFullMatrix

> The parameters of the functions in the type librairy are :

> FUNCTION GetFullMatrix  (in Interface)

> returnType :    HResult
> parameters:
>                       name : BSTR [in]
>                       worskace : BSTR [in]
>                       pr : safeArray of double* [in,out]
>                       pi : safeArray of double* [in,out]

> FUNCTION PutFullMatrix  (in Interface)

> returnType :    HResult
> parameters:
>                       name : BSTR [in]
>                       worskace : BSTR [in]
>                       pr : safeArray of double [in]
>                       pi : safeArray of double [in]

> The program look's like this :

> var
>     FMatlab : Variant;
>     pr,pi : Variant
> begin
>     // work correctly; the application open...
>     FMatlab := createOleObject('Matlab.application');
>     // work correctly; I execute command in the server
>     FMatlab.execute('a=13;');
>     // This is one of the way I try to initialise the variable pr and pi

> (safeArray)
>     pr := varArrayCreate([0,1],varDouble);
>     pi := varArrayCreate([0,1],varDouble);
>     // Error
>     FMatlab.putFullMatrix('myVariable','workspace',pr,pi);
>     ...
> end;

> When I execute the last line I always have this error :
>            project1.exe raised exception class EOLESysError with message

> 'Types non correspondants'
> Or this one
>            project1.exe raised exception class EOLESysError with message

> 'Types mismatch'

> What can I do?

> Thanks for your help...

> Vincent Lapointe

Re:problem when calling two method of an automation server


Try this:

FMatlab.putFullMatrix('myVariable','workspace',PSafeArray(TVarData(pr).vArra
y),
    PSafeArray(TVarData(pi).vArray));

have fun
--
Binh Ly
http://www.techvanguards.com

Quote
"Vincent Lapointe" <lapointe_vinc...@hotmail.com> wrote in message

news:3A660CF4.90987C71@hotmail.com...
Quote
> I want to create a new instance of an automation server application and
> use some of the function available, but I always have an exception error

> when I call one of this function : getFullMatrix or putFullMatrix

> The parameters of the functions in the type librairy are :

> FUNCTION GetFullMatrix  (in Interface)

> returnType :    HResult
> parameters:
>                       name : BSTR [in]
>                       worskace : BSTR [in]
>                       pr : safeArray of double* [in,out]
>                       pi : safeArray of double* [in,out]

> FUNCTION PutFullMatrix  (in Interface)

> returnType :    HResult
> parameters:
>                       name : BSTR [in]
>                       worskace : BSTR [in]
>                       pr : safeArray of double [in]
>                       pi : safeArray of double [in]

> The program look's like this :

> var
>     FMatlab : Variant;
>     pr,pi : Variant
> begin
>     // work correctly; the application open...
>     FMatlab := createOleObject('Matlab.application');
>     // work correctly; I execute command in the server
>     FMatlab.execute('a=13;');
>     // This is one of the way I try to initialise the variable pr and pi

> (safeArray)
>     pr := varArrayCreate([0,1],varDouble);
>     pi := varArrayCreate([0,1],varDouble);
>     // Error
>     FMatlab.putFullMatrix('myVariable','workspace',pr,pi);
>     ...
> end;

> When I execute the last line I always have this error :
>            project1.exe raised exception class EOLESysError with message

> 'Types non correspondants'
> Or this one
>            project1.exe raised exception class EOLESysError with message

> 'Types mismatch'

> What can I do?

> Thanks for your help...

> Vincent Lapointe

Other Threads