Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Question about DLLs...

Author
Message
PolyVector
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Ghetto Land
Posted: 27th Mar 2003 00:44
I'm trying to use a DLL function that returns coordinates of an object....it returns 4 bytes for each variable "XXXXYYYYZZZZ"... my problem is that if i use a string$ to get the info it truncates the return when it hits a hex value of 00... so i ONLY get the X coord unless say...X is negative or whatever....

Basicly it's a simple question, how do I get 3 variables returned from a DLL Function???
Thanks, Poly
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Mar 2003 00:49
The easiest way is to allocate memory in DBPro, pass the address into your DLL and store the data there.
Then, use a peek/poke plug-in, you can read the values...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Mar 2003 01:22
If I was coding it, I'd do it exactly like DBPro does at the moment - use a separate command/function to get each value. This way, your DLL works in the way people already expect and are used to.
PolyVector
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Ghetto Land
Posted: 27th Mar 2003 02:02
Yeah, that would work but I don't have the source to this DLL...
I know what I want to do is possible...and my string idea works until it hits the character 00.....hrmmm.......
--Poly

PolyVector
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Ghetto Land
Posted: 27th Mar 2003 02:26
Solved it!!!
-----------------------------
REM Setup Memory
make memblock 1,12
memblockptr = get memblock ptr(1)

REM Return Variables
tempptr=call dll(1,"dBodyGetPosition",body)
copy memory memblockptr,tempptr,12

REM Get Variables
x#=memblock dword(1,0)
y#=memblock dword(1,4)
z#=memblock dword(1,8)

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Mar 2003 14:10
Hmmm... Memory leak? Where is the memory pointed to by 'tempptr' being deallocated?
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Mar 2003 14:11
I bet half of his code got chopped off...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2026-07-11 14:36:45
Your offset time is: 2026-07-11 14:36:45