Board index » delphi » Changing VB array via delphi dll....

Changing VB array via delphi dll....

The Knowledgebase shows how to pass a VB array to a delphi open array.
However, this method cant be used to return a changed array safely.

To avoid the VB API one could pass the first array element , say a
single , by reference, and use a single pointer to change the rest of
the  elements. This approach assumes, that VB array elements are
always neatly lined up in memory so that a(1) is 4 bytes from a(0)
etc.

Is that true?
(It seems to be true, but I dare not make any assumptions about it)

Soren Haastrup  (s-haast...@dk-online.dk)

 

Re:Changing VB array via delphi dll....


Quote
s-haast...@dk-online.dk (S. Haastrup) wrote:
>The Knowledgebase shows how to pass a VB array to a delphi open array.
>However, this method cant be used to return a changed array safely.

>To avoid the VB API one could pass the first array element , say a
>single , by reference, and use a single pointer to change the rest of
>the  elements. This approach assumes, that VB array elements are
>always neatly lined up in memory so that a(1) is 4 bytes from a(0)
>etc.

>Is that true?

        Yes. (At least that's what the manual says...)

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...

Re:Changing VB array via delphi dll....


In article <3115436...@193.89.47.9>, s-haast...@dk-online.dk says...

Quote
>To avoid the VB API one could pass the first array element , say a
>single , by reference, and use a single pointer to change the rest of
>the  elements. This approach assumes, that VB array elements are
>always neatly lined up in memory so that a(1) is 4 bytes from a(0)
>etc.

>Is that true?
>(It seems to be true, but I dare not make any assumptions about it)

It seems to be true every time i have tried. Beware however that in
multidimensional arrays the indexes are in reverse order:
  VB_Array[i,j] = Pas_Array[j,i]

--
Sverre A.C. Kittelsen                 e-mail: s.a.c.kittel...@snf.uio.no
Research Economist                                    tel.: +47-22958815
SNF Oslo                                               fax: +47-22958825
Gaustadalleen 21                                     priv.: +47-67141662
N-0371 Oslo, Norway

Re:Changing VB array via delphi dll....


Quote
s-haast...@dk-online.dk (S. Haastrup) wrote:
>The Knowledgebase shows how to pass a VB array to a delphi open array.
>However, this method cant be used to return a changed array safely.

>To avoid the VB API one could pass the first array element , say a
>single , by reference, and use a single pointer to change the rest of
>the  elements. This approach assumes, that VB array elements are
>always neatly lined up in memory so that a(1) is 4 bytes from a(0)
>etc.

>Is that true?
>(It seems to be true, but I dare not make any assumptions about it)

>Soren Haastrup  (s-haast...@dk-online.dk)

It is true for static arrays, but not for dynamic arrays. For dynamic arrays, the VB API must be used.

Re:Changing VB array via delphi dll....


In article <4fnber$...@oznet07.ozemail.com.au>, rhend...@ozemail.com.au
says...
Quote

>s-haast...@dk-online.dk (S. Haastrup) wrote:
>>The Knowledgebase shows how to pass a VB array to a delphi open array.

[stuff deleted]

Quote
>It is true for static arrays, but not for dynamic arrays. For dynamic
> arrays, the VB API must be used.

Could you please elaborate on the VB API ?

Any pointers to references would be greatly appreciated ! (i've already
tried searching the M$ web server, to no avail.

thanks in advance,

Mat

m.ball...@chem.csiro.au

Other Threads