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 / going mad with DLLs and returning strings. bug???

Author
Message
skyser
22
Years of Service
User Offline
Joined: 11th Sep 2003
Location: New York, NY
Posted: 6th Oct 2003 00:36
so i'm writing a DLL and generally have the hang of things, but there is a quirk which is driving me crazy and i can't figure it out. it's one of those "how can this one thing possibly affect the other?" bugs.

so here goes...

* i've got lots of working functions that take multiple int parms and spit back int values. they all work fine. typical string table entries might be: INT FUNC[%LL%?myIntFunc@@YAHHH@Z or INT FUNC2[%LLL%?myIntFunc2@@YAHHH@Z

* i've got a working test function that takes no args and spits out a string. it's string entry looks kind of like: STR FUNC[%S%?myStrFunc@@YAKXZ

so far so good.

now all of these functions make use of a global map collection that is referred to by an index. so a typical function looks like:


this works fine for a million little functions returning ints. however it consistently reports a bad map index any time i try to return a string. so, for instance:

this might have the string table entry: STR FUNC[%SL%?myStrFunc@@YAKXZ

so, to try and put it all together and explain... within DB i can have the following lines:



any tests i do where i set the index internally, make the problem go away. so for example:



argh! this is driving me nuts. does any one have some insight or sample code to share?

yours in madness,

--skyser
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Oct 2003 00:48
its because your trying to link a value which isn't there, when you return strings if it isn't NULL then you must declare a blank string by creating a DeleteString first - then you can pass back the string value you wanted to, which is just a DWORD pointer.

checkout the TestCommands2 example in the SDK documentation as well as the readme on this as it explains it far better than i can.

simply fact is that you're creating a string, but what dbp need is a string instance pointer value - you can't simply pass back a string like

return (*DWORD) strMyString[index];
dbp has its own way of doing things internally.

skyser
22
Years of Service
User Offline
Joined: 11th Sep 2003
Location: New York, NY
Posted: 6th Oct 2003 00:51
thanks again raven, i'll give it go...

but i still don't understand how any of this can affect the index value, which is just an int...

--skyser
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Oct 2003 00:52
its because your trying to pass it back as a string rather than an integer if you just changed it, would be hunky dory

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Oct 2003 02:13
Grab the Framework and Utility dlls from my site - source included

Login to post a reply

Server time is: 2026-07-25 09:59:16
Your offset time is: 2026-07-25 09:59:16