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 / DBP Plugin string table format and output/input parameters

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2007 11:25 Edited at: 25th Apr 2007 19:18
This is to share some information about the format of DLL string tables for DBP plugins, and some other similar stuff as well that I have learnt



The special function means that although the user writes it as a command, it acts like a function. This means that it returns a value, and places it in the variable which used as the parameter before the *. An example of this is the read byte command. The compiler places its return value into a specified variable. The string table entry for this command contains these letters: LS*. The star tells the compiler to put the result of the function into the variable used for S

The decorated function name can be found by opening the compiled dll in notepad, and searching for your function name. The letters and symbols together with the function name make up the decorated function name

Format of string table entries:

Each section is seperated by the % symbol.

Command:
Dark basic command name%Parameter letters%Decorated function name%Parameter description

Example:
Show example%SS%?ShowExample@@YAXKK@Z%String message, string caption

Function:
<The first parameter letter is the return value>
Dark basic function name[%Parameter letters%Decorated function name%Parameter description

Example:
Get example[%SS%?GetExample@@YAKPAD0@Z%String caption

Command with no parameters example:
Start example%0%?StartExample@@YAXXZ%*No parameters*

Special function example:
Clear string%S*%?StartExample@@YAKHK@Z%String to clear
This special function will return "". This is placed in the variable for S, clearing the previous value.

If anybody knows any more things to do with this, please post them, and I'll add a section about them

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Mar 2007 11:50
Um, your table has the wrong letters in it.

Double integer = R
Double float = O (letter, not number)
String = S

and * does not mean pointer. It's a way for a function to look like a command, and doesn't mean that you can return more than one variable.

Clear string%S*%?ClearString@@YAPADPAD@Z

is functionally equivalent to:
Clear string[%S%?ClearString@@YAPADPAD@Z

both require a function like:
char* ClearString(char* OldString)

You also don't need to cast every type you return. Only the float type need to be cast to a DWORD.

Here's a little trick for you - if you set the return type to a double float, you *can* return a float and not have to worry about casting the value - good if you are returning a calculation result and don't want to bother creating a variable just to cast the result to return it.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2007 13:13
If it is not a pointer, then why do all the dll functions that use * require an extra DWORD parameter to call them then?


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Mar 2007 14:02
Point one out to me and I'll tell you.

For example, all of the read functions in core, except for the string one have no parameters, and the one for the string is for the oldstring pointer.



Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2007 14:15


Those both have a DWORD parameter where there is a * in the string table.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Mar 2007 14:57
The DSDK is not the same as the DBPro DLL's - you can't use the SDK to prove something in the DLL's

Those two functions from the DLL's:


In the last one, the second argument is the oldstring pointer - that's the only peculiarity of passing an S* ... the oldstring is not the first argument that is passed to your function.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2007 15:04
Those weren't from the DSDK
They were extracted directly from the DBPro DLLs

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Mar 2007 15:20
How? Using someone's 'converter'? They are wrong!

If you have undname, or can get hold of an equivalent piece of software, then use that to decode the mangled C++ names like I do.



Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2007 15:30
So the DBP compiler swaps it around?

eg.
read byte 1,b

is actually:

b = read byte(1)

If that is the case, then I understand now I will edit my first post!

drdoo
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 22nd Mar 2007 02:10
diggsey wrote
Quote: "
The special function means that although the user writes it as a command, it acts like a function. This means that it returns a value, and places it in the variable which used as the parameter before the *. An example of this is the read byte command. The compiler places its return value into a specified variable. The string table entry for this command contains these letters: LS*. The star tells the compiler to put the result of the function into the variable used for S
"


So in effect it turns a procedure into a function allowing the result to assigned to 1 of the parameters.

Surely it must be possible to return or modify more than 1 variable from within a TPC Dll ??

Looks like the only solution is to use MMF (Memory Mapped Files) for updating more than 1 variable passed between a DB and a TPC Dll.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 28th Mar 2007 15:02
Hi,

I wanna thank you for your post
It gives me some informations I didn't have to make PurePLUGIN handle more additional plugins ...

Bye

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Mar 2007 19:31
@drdoo
The easiest way, is for the function to return one value, and then have seperate functions to return the other values

@Freddix
Thanks!

TinTin
18
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 19th Apr 2007 18:07
I wonder if you can return a UDT?

I haven't tried this yet, I'll give it a go tonight if I get the time.

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Apr 2007 00:59
Not really.

If you pass back a 4 byte UDT, it should be retrievable as an integer, float or dword.
If you pass back an 8 byte UDT, it should be retrievable as a double integer or double float.
If you pass back a larger UDT, then all bets are off as the way those values are returned are completely different.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 25th Apr 2007 07:43 Edited at: 25th Apr 2007 08:14
@Diggsey
OOoooo.... Someone actually IS using my Dev-C++ Plugin Template.
Also, those DWORDs are accidental.... I will swap them around to make them work later

Edit
There is also, I believe, "X" for any type, and "H" for an array.

Edit 2
Yup, H is array.



@IanM
He's using my library, which makes it MUCH easier to make a DLL for dbp. For example:


Edit 3
What does this mean IanM? Specifically the "Y" part..


Cheers,

-db


What? You mean I cant sleep here???
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Apr 2007 10:21
'Y' is the only one I haven't worked out - as that read command is the only one I know that uses it, I've never been too worried about it. Maybe one day I'll take the time to investigate further.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 25th Apr 2007 19:13
Maybe it means that the function returns the same type as the variable used, and goes with the *

Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 9th May 2007 18:58 Edited at: 9th May 2007 19:45
About File reading.
If I understand correctly, under purebasic, I may do this :

(*DB_FileReadByte is pointer to the ReadByte function)
because it's a function and not a command ... right ?

I tried this and it crash my app

Same for ReadString:



EDIT:
In fact it was the ReadString that did crash:p
ReadByte,word and long work :


Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor

Login to post a reply

Server time is: 2024-11-22 17:01:07
Your offset time is: 2024-11-22 17:01:07