[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning an array from a C++ DLL?



PureBytes Links

Trading Reference Links

Make the array in tradestation
e.g., array: myarray[100]

Pass the array to a DLL

e.g., definedllfunc: "MYDLL", void, "MYDLLFUNC", lpfloat
remembering that arrays will always be filled with floats
MYDLLFUNC(&myarray[0]);
pass the 1st address of the array to the DLL

In the DLL use pointers to manipulate it such that changes made to it are permanent
e.g. in C++ define it as:
void __stdcall MYDLLFUNC(float * myptr)

Manipulate it in C++
e.g., *(myptr+2) = 5
to assign the value of 5 to the ***2nd*** element

remember, in C++ you normally count one-dimensional arrays by one. myptr, myptr+1, myptr+2, etc..

but when passing an array from TS, count by two - myptr, myptr+2, myptr+4, etc..

also experiment with passing 2 dimensional arrays Tradestation - it counts them differently in memmory than C++ normally does (i wont' go into that, you can play with it on your own to see what's happening).

-Alex

Ivo Karindi wrote:

Assuming it can be done, can someone point me to the right syntax?

TIA,

Ivo Karindi