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.

DLL Talk / Returning Strings from DLL to DBP

Author
Message
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 7th Sep 2004 11:50
Alright, can someone please explain to me how to return strings in the dll to DBP, because I just don't get how it works. The example in the help file shows the ReverseString function returning a DWORD. For the life of me, I can't even figure out how to use the function after compiling the C++ project that came with DBP.


High quality models and graphics, low prices. Graphics for the rest of us.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 7th Sep 2004 17:10
Essentially you need to return a DWORD pointer to a char pointer :



You need to use the CreateDeleteString to deallocate previous string memory and allocate new memory.

Then, in the resource file, you use 'S' as the input/output parameter, so its something like :

reverseString[%SS%ReverseString%Reverses a string

If your not going to return a string (ie its just passed as a parameter), then DWORD pOldString isn't needed.

The command will then be called using :

a$=reverseString("TEST") - Note : 2 parameters are not passed, as we should not count DWORD pOldString as one.


Come to the UK Convention on the 23rd & 24th of October
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 7th Sep 2004 23:02
Can you give me an example of what the passed parameters would be if I wanted to return a string with the ReverseString function? I can't figure out what that second parameter is supposed to be.


High quality models and graphics, low prices. Graphics for the rest of us.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 7th Sep 2004 23:06 Edited at: 7th Sep 2004 23:07
The first parameter (OldStr) is always there if you're returning a string, it's basically a pointer to the memory where the final string to be returned will end up.

As such, any parameters after that will be the normal command parameters, so, in the ReverseString example, the second parameter will hold the string you actually want to reverse. The command would be called like this:



Then, if you checked the value of 'pStringIn' in C++, it would hold the string: "Reverse This String". Remember, the OldStr variable is just used to return the string properly, it's there to solve memory issues.

Hope that helps at all.


"Computers are useless they can only give you answers."
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 7th Sep 2004 23:13 Edited at: 7th Sep 2004 23:23
Exeat, mind if I MSN you?

OK, I do this:



and all that happens is the executable starts, then exits without displaying anything.


High quality models and graphics, low prices. Graphics for the rest of us.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 7th Sep 2004 23:27 Edited at: 7th Sep 2004 23:31
DBP DLL's aren't used like, you need to copy and paste them in the "DBPCompilerPlugins-User" directory. Then you can just call the command like any other command, just type it's name and parameters in.

Quote: "Exeat, mind if I MSN you?"


Not at all, go ahead.

Edit: I have to go now though, so I guess you'll have to get TCA or someone else to help you if you still can't get it working. Feel free to add me anyway though.


"Computers are useless they can only give you answers."
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 7th Sep 2004 23:32
'Cept, I did that and I get an error message.

Subscript must be Integer or DWORD when referencing an array at line 20.


High quality models and graphics, low prices. Graphics for the rest of us.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 7th Sep 2004 23:36
Make sure you've added the command to the string table in the DLL and that the DLL is in the right directory, also make sure you spelled the command right in the editor. You usually get that error because it thinks you're accessing an array CommandName(Parameter) could well be an array of variables rather then a function that returns a value. So yeah, it basically means it couldn't find the command you entered.


"Computers are useless they can only give you answers."
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 7th Sep 2004 23:42 Edited at: 7th Sep 2004 23:42
I'm using the project that came completed with DBP. It was my assumption that the string table was already completed. And it does in fact have a string table entry.




High quality models and graphics, low prices. Graphics for the rest of us.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Sep 2004 03:32
I used to get crashes like you are describing when the Core pointer wasn't available. You need to ensure that your ReceiveCoreDataPtr is defined correctly to get the data pointer passed to your DLL.

You can test this by putting the following line of code in your ReverseString function as its first instruction:



Maybe you should download my framework example to see how its done - I've fully commented the code and put other details in the Readme.txt too

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 8th Sep 2004 03:40
I have your framework, but I figured I'd try to do the 'basic' tutorial that came with DBP... I guess it's not so basic after all.


High quality models and graphics, low prices. Graphics for the rest of us.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 8th Sep 2004 03:54
You would call the function like :

a$=reverse string("test")
print a$

It is possible that the function name (between the first and second %) is incorrect for your compiler.


Come to the UK Convention on the 23rd & 24th of October
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 8th Sep 2004 04:26
IanM, yep, that was it. No pointer


High quality models and graphics, low prices. Graphics for the rest of us.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Sep 2004 04:46
So are you all sorted now?

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
JeBuS
19
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Undisclosed Location, Dominion of JeBuS
Posted: 8th Sep 2004 05:10
No, but I've given up on the example in the help files and moved over to your framework.


High quality models and graphics, low prices. Graphics for the rest of us.

Login to post a reply

Server time is: 2024-03-28 21:13:19
Your offset time is: 2024-03-28 21:13:19