-
Dan Cooperstock
- PowerBuilder
- Wednesday, 5 August 2026 07:07 PM UTC
I'm at my wit's end!
I just want to pass a numeric array from an object to a C DLL I have written, in such a way that changes made to the array in the DLL are reflected when the external function call returns to PB (i.e., the call is by reference).
I've gotten a great deal of conflicting advice from different AIs, none of which have worked.
The array is declared as long in PB, and as __int32 in my C code. To match C calling conventions, I declared the array in PB with array bounds starting at 0. (I.e. arr[0 to 80] - it's trying out some C code for sudoku solving!)
Nothing seems to work. If I use code that passes the array successfully, it always seems to be a copy, so changes don't persist.
One AI suggestion was to declare the external function argument as just "REF long arr" (not indicating it's an array!), and in the actual function call, use "REF arr[0]" as the argument. That almost worked, except when I looked at the received array in the Visual Studio debugger, alternate values were the correct values that I was trying to pass in, and the values in between were some fixed constant. (That suggested a data type mismatch to me.)
There were also suggestions from AIs (perhaps hallucinations) that the variable I was passing in had to be a local variable in a function; that an instance variable in an object (which I would have preferred to use) would always be passed as a copy. Does anyone know if that's true?
Any bright ideas on what works reliably? Thanks.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.