If "CallFunctionFast(func,#PI/4.0) " retrieves an address, you should use a pointer.
"@v1+OffsetOf(cpVect\x)" makes an offset to the adress of the long variable and not of the retrieved address.
The original source posted can't work, in my opinion, because @v1+OffsetOf(cpVect\x) ends up in memory allocated by PureBasic and we really don't know what we're going to read.
The Hroudtwolf version seems correct, and maybe the problem lies in the return value of the library function, or in the way it's being called.
I would check those things.
Are you sure the memory area returned by your DLL is static (persistent even after the function call) and not locally allocated on the stack ? That would explain such behaviour.
Since you're reading memory used internally by Purebasic, changing the valour of variables modifies this memory and you're obtaining different results.
Fred wrote:Are you sure the memory area returned by your DLL is static (persistent even after the function call) and not locally allocated on the stack ? That would explain such behaviour.
@Fred,
Seems to be not static.
=> @Fred have you some hints for me for a working PB source?
iNX wrote:Since you're reading memory used internally by Purebasic, changing the valour of variables modifies this memory and you're obtaining different results.
PB bug?
Belive! C++ version of Puzzle of Mystralia <Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
iNX wrote:Since you're reading memory used internally by Purebasic, changing the valour of variables modifies this memory and you're obtaining different results.
PB bug?
No, no.. it's normal behaviour. We are not supposed to read memory in this way.
Unfortunately i can't be of much help other than explaining why your code was acting that way. In fact now your problem narrows down to handle a library call that returns a structure, instead of a pointer to a structure.
I don't know how to handle such case in purebasic, i think it's not natively supported. Hope someone could be of more help.
Fred wrote:Are you sure the memory area returned by your DLL is static (persistent even after the function call) and not locally allocated on the stack ? That would explain such behaviour.
@Fred,
Seems to be not static.
=> @Fred have you some hints for me for a working PB source?
If it's not static, then the result are stored on the stack. Assigning a structure to a structured PB variable is not supported natively by PureBasic, so you will have to copy it as soon as possible, without destroying the stack in between (which can be difficult). It's not a PB bug.