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

Passing a numeric reference array again



PureBytes Links

Trading Reference Links

Hopefully I explain this properly :D

Let's say you have a signal (mysignal) and in it you declare an array
array: myarray[5](0);

Now, you have a function(myfunction) that will take the array, and permanently modify the values (hence you want to pass it to the function by numeric reference)

so in the signal you go : myfunc(myarray)

and in the function 'header', you declare: inputs: myarray[length](numericarrayref);

Okay, so now in the function you can play array with it and change values in the array, etc...
Okay, now here's the kicker - in the function, let's say you want to display the memory address of the myarray[0] ; you'd go &myarray[0] .... but guess what - invalid pointer operation.

Why would I want to access the memeory address of the 1st element anyways? - because, in that function I've got a DLL call (written in C++) that will take the array, and modify it - so in the DLL i've declared a floating pointer to store the address of the array (float *myptr); hence I have to pass the address of the array to the DLL by calling something like MYDLL(&myarray[0]). Well - because the array was passed by numeric reference, I can't use it's memory address (invalid pointer operation in Easylanguage) in the function code, only in the initial signal code where it was created.

Any thoughts on how to get around that? The only solution I've had so far is to write a function in the DLL that will store the memory address of the array. Then, in the signal part of the code, as soon as the array is created and initialized, I call the DLL function that will store the memory address, and then store the memory address to the array globally.

That way, in the function part of the tradestation code, I don't have to pass the address of the array because it's already been passed, so the DLL knows exactly where the array is in memory.

It's a good solution imho, but it does leave me wondering something - how can you create an array in a signal, pass the array via numeric reference to another function, then pass the array (from the function) into a DLL function (using pointers) w/o generating an invalid pointer message.

Perplexing?

-Alex