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.

Program Announcements / PurePlugin, a practical work-through example...?

Author
Message
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Mar 2007 09:17 Edited at: 26th Mar 2007 09:42
Hi Freddix,

Just bought PurePlugin and having difficulty getting my head around the various concepts.... thought it might be useful (for me, probably for others) if you could take me through a basic example...

Say I wanted to create a dll with the following three commands:-

D_Move Object Left (utilising DBPro Move Object Left);
D_Move Object Right (utilising DBPro Move Object Right); and
D_GetFreeObject (finding next free object utilising DBPro object exist()).

Getting the work-through started:-

1. what would be my code in Purebasic .pb file?
2. the constructor, destructor etc... do they go all in the same one .pb file? if not, how do you include them (in idiot-proof terms)?
3. what are the res files? where should they be placed?
4. would it make any difference if I intended 3 or 300 commands in my dll when considering questions 1-3 above?

[edit] it occurs now that this thread might be better placed on a different forum - perhaps the DLL one? will leave that to a moderator if thought necessary...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 26th Mar 2007 15:20
Hi,

I will try to answer correctly your question but, I will probably not give all details here because it may be too long to explain.

1. What would de my code in PureBASIC .pb file ?
What user have to know is that your PB source code will have to follow the sample one that makes all includes for you.
Here is the default sample source code for upcoming 1.1 upgrade:

As you can see, there are many sections in that file and also many includes.
I will describe them :

[PluginVERSION Checker]

These few lines define 2 values : PurePLUGIN\Version and PurePLUGIN\Revision. Their values will then be the reflect of the installed Compiler\PLugINS-User\PurePLUGIN.dll version
You can read them from within your PureBASIC source as standard integer value to know which version will be used. It's useful if someone overwrite the PurePLUGIN.dll version with an older version that does not handle additional plugins you need for your plugin to work.

[User Identification]

To make PurePLUGIN.dll send you the needed informations to use DarkBASIC Professional DLLs and additional plugins, you'll have to put your UserNAME and UserCODE here (we advice you to crypt them and decrypt them in memory to prevent someone from ripping your IDs)
Please, becarefull with PurePLUGIN.dll, if you're not sure it's an original one. I will put a link for the latest PurePLUGIN.dll file at www.odyssey-creators.com so, you can be sure that the version on the site is the original one.

[DLL constants

This file add extra informations to know if a DarkBASIC Professional DLL or Additional plugin was included in the final DarkBASIC Professional application that use your plugin.
How it work ?
It simply add informations this way :

With that, you can call PurePLUGIN.dll to know if a DLL was loaded. for example, for the DarkBASIC Professional DBproBasic2D Debug DLL, do this in your PC Source code :

If Result = 1, then the DLL is loaded and can be used from your plugin.

[DLL Structures]

These two includes setup all needed structures to use DarkBASIC Professional DLL and additionals plugin from your own one.


[The DarkBASIC Professional and additionals plugins commands sets]
The next includes files add the needed Procedure to call directly DarkBASIC Professional and Additional plugins commands from your own plugin:


[Plugin Activation]
If your plugin is correctly initializd with PurePLUGIN.Dll, you'll receive the informations and the value:

will be set to one.
You can check this from everywhere in your plugin to know if it is activated or not. If not, you can't use DarkBASIC Professional and Additional plugins commands from your own plugin and a popup message will appear on DarkBASIC Professional application that'll use your plugin saying it is not activated.

[The Constructor procedure]
DarkBASIC Professional can make some initialisations from the Constructor command. the main problem is that PureBASIC can't compile DLL with functions using decorated form. You'll then have to make changes from yourself after compilation:

This procedure makes all initialisation of the plugin.
Once your DLL is compiled, you'll have to modify the procedure name with an HEX editor (it will be explained later)
The PPInit() procedure do the same job but is here for security reasons.


[Your DLL commands]

This include will add a file where you can put all your ProcedureCDLL that will make the final DarkBASIC Professional commands you've created.

Here are all the informations about the main DLL .pb file.

All your procedure will follow the same scheme that I explained months ago in the old PureBASIC tutorial on TheGamecreators Newsletter :
http://www.thegamecreators.com/data/newsletter/newsletter_issue_22.html#17 but updated to new DarkBASIC Professional internal specifications and with a more stable and professional way of working (and also faster :p)

Once you've compiled your DLL, you'll have to use a tool like RESOUCE HACKER to add String Table. This part of a DLL development is explained in the Tutorial on the newsletter and in the PurePLUGIN Help. I'll just comment here that String table are the direct link between your DLL procedures and DarkBASIC Professional commands you've created.

The last part of the development will be to replace (with an HEX editor like freeware XVI32) the AConstructor00YAXXZ command with ?Constructor@@YAXXZ
It's an easy task that will take less than 1 minutes to achieve :p And is needed because DarkBASIC Professional doesn't know non decorated Constructor function.

I hope these explanations answered your questions 1, 2 and 3.

Technically, you can add as many new commands as you want. for example, my XQuadEditor.DLL developed in PureBASIC add more than 300 new commands handling all the X-Quad Editor game engine structures and functionalities. PureBASIC Can do more, and PurePLUGIN Handle this too
The only differencies will be that, more commands you'll have in, bigger the DLL will be. (and more String Table you'll have to do to create the new commands)

I Hope I've answered all your questions.

Regards,
Fred

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Mar 2007 15:34
@ Freddix,

That's great - your reply really helps bring on my understanding of this - so I can simply write my procedures in a seperate .pb to be included towards bottom of default sample source code .pb?

1. What are the res files for?
2. How do I know what one of your commands to use within a Purebasic .pb to activate the reciprocal dbpro command? Where are the lists?
3. Do I just then compile to a dll the main source code .pb which includes all the other files (including my .pb procedures file for new commands?)?

Again your replies are helping me (and no doubt others) get to grasps with this plugin...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 26th Mar 2007 15:53
1. The .res file contain string table. String table is a list containing all ProcedureCDLL - DBProCommands links
For example :

In this line you'll have :
DBP Test : The DarkBASIC Professional created command.
L : Parameter to give to the command
MyProcTEST: The ProcedureCDLL contained in the Plugin DLL you've created.
TestValue: Information on the parameter(s) of the commands.

When you want to create your DLL, you'll simply have to:
-Open in the PureBASIC Editor the main .dll file, modify the included procedures one (where you'll put all your new commands in, by opening it too in the PureBASIC Editor)
-Put your username and password in the defined area.
-Compile the DLL (with your final DLL name)
-Delete .lib and .exp files created by PureBASIC (They're useless for us)
-Open your .DLL file with Resource Hacker
-Insert a new string table and modify it (using help provided in PurePLUGIN help and in the old TPC tutorial)
-Make changes save
-Open your DLL with XVI32 Hex Editor And use Replace command to modify the Constructor procedure NAME
-Save changes
-Copy your DLL and PurePLUGIN.Dll in the DarkBASIC Professional Compiler\Plugins-user directory.

Here is the full procedure to create a TPC Plugin with PurePLUGIN.

If you want to know which commands are technically supported, open the files located here:
-DBPro_Commands folder : All native DarkBASIC Professional commands sorted out by DLL name (each on a separate file)
-DBProPLUGIN-LICENSED_Commands folder : All Licenses plugin supported. Don't forget that if you use a licensed plugin from your own one, that both you and your users will have to own an activated version of the licensed plugin you use.
-DBProPLUGIN-USER_Commands folder : All supported plugin users. Same remark than for licensed plugins. You and Users must have the plugin user plugin installed to make your plugin to work correctly.

The command that initialize all DBPro's and additionals plugins commands is the InitDLLBase() one.
It is called in the Constructor and PPInit... one to be run when your program start so, you'll don't have to call them from a procedure within your DLL they may be called by DBPro on startup.

Regards,
Fred

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Mar 2007 20:56
@ Freddix, thanks for all of that...

...so I can ignore the res files more or less?

... perhaps an obvious answer but where do I find my own username and password within the stuff I downloaded...?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 26th Mar 2007 22:30
No, you can't because DarkBASIC Professional uses the String table contained in the .RES file inserted in the TPC DLL to create the new commands sets.

For the Username and password, they are sended by mail with informations for download links

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
griffirr
20
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 27th Mar 2007 00:41 Edited at: 27th Mar 2007 00:45
I have something to add here that may be usefull. I'll try not to confuse.

First you can make a .rc file for your string table in the following format. Then you can add this to your project in PureBasic under "Compiler-Compiler Options-Resources". PureBasic will then automatically build the string table everytime you compile.

String Table Format (save as .rc file) file shows version 1.1 example string table.


I have also attached a zip file containing the above resource file "script.rc". Also included in the zip is a small executable written in PureBasic (source included) that will correct the constructor/destructor on your PurePlugin dll.

Using these to methods I have removed the need for hex editing and resource hacking.

Hope this is helpfull.

Attachments

Login to view attachments
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 27th Mar 2007 09:25
Hi Griffirr,

Thanks for this useful information about RC resources, it will be added on next release (1.2 :p)

You said you removed the step to hex editing ?
But then, DBPro will not run the Constructor function. BEcause HEX Editing make Constructor function compatible with DarkBASIC Professional startup.

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Mar 2007 09:39
@Griffirr,

If that works it seriously ups the accessibility of the plugin...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
griffirr
20
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 27th Mar 2007 12:00
Freddix,
The hex edit is now done using the PPFixer tool in the zip. Running it opens a dialog to select a plugin (.dll) and then it modifies the constructor function names for you.

Question: THe PPFixer I made modifies both the constructor and destructor. Should it only modify the constructor? If so you can modify the included source the remove the destructor modification.
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 27th Mar 2007 13:06 Edited at: 27th Mar 2007 13:07
Here is a getFreeObject procedure that works...



"getFreeObject()" is the procedure you can call from DBP. "inc" is a lame little function I wrote to ease translation of DBP code to PB. It is a regular procedure that does not get called from DBP.

I haven't actually turned that into a command yet, but I will, and will add an optional flag to keep track of the last object returned so it doesn't have to keep counting from 1.

This will work, provided you've set everything up like Freddix showed you, and then you add that command to the DLL string table. It's very easy though, you can just copy Freddix's example each time you want to make a new DLL and just build on his template.

Commands like "D_Move Object Left" and "D_Move Object Right" would be kind of pointless for me to write out, since you can just call those commands directly in the PB code, and they already exist in DBP. It would be ridiculously simple though, all you would have to do is call the procedure "DBMoveObjectLeft( ObjectNumber.l, Value.f )" in PB like any other function.


Come see the WIP!
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 27th Mar 2007 13:08
no, leave it modiify both :p it's better if someone want to put something in the Destructor (the function called when your DBPro app exit)

Do you agree if I include your PPFixer tool in the PurePLUGIN Package for future users ?
(otherwise I can make like for Resource Hacker and XVI32, get link for your tool)

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
griffirr
20
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 27th Mar 2007 14:19 Edited at: 27th Mar 2007 14:22
You can include them in the release for future users. I hope this helps people to utilize PurePLUGIN as it is a great way to quickly impliment fast, small in size plugins for DBP.
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Mar 2007 15:32
@ Cash Curtis II - as ever, code v helpful,

@ griffirr - v helpful.

@ freddix - wait eagerly then for v1.2

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 30th Mar 2007 14:27
@ Freddix,

You going to include details and files as indicated by Griffirr in next update 1.3?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 30th Mar 2007 17:32 Edited at: 30th Mar 2007 17:32
I don't know.
I will maybe include them as an external link (because they're not Odyssey-Creators property, I can't really include them in the PurePLUGIN Package)

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 30th Mar 2007 18:50
@ Freddix,

That would be great - I was thinking in particular of you incorporating into your files and examples the .rc file he mentioned:-


String Table Format (save as .rc file) file shows version 1.1 example string table.
+ Code Snippet
STRINGTABLE DISCARDABLE
BEGIN
1 "PPI Integer Comparizon[%LLL%MyComparison"
2 "PPI Float Comparizon[%FFF%MyComparisonF"
3 "PPI String Len Comparizon[%SSS%MyLenComparisonSTR"
4 "PPI Rotision Object%LFFFFFF%MyPosRotObject"
5 "PPI Show PurePLUGIN Version%0%ShowPurePLUGINVersion"
END

etc

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
griffirr
20
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 30th Mar 2007 18:57 Edited at: 30th Mar 2007 18:58
Freddix,
It is okay with me if you include the files in your package. That is why I included the source for the .exe. Feel free to change the source, add your company name or whatever you like. I just made it to reduce the chance of messing up the hex editing and to make the process quicker to use.
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 30th Mar 2007 19:22
Ok
I'll include them.
But I'll give credits to you about your "free contribution"

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Apr 2007 22:05
@ Freddix,

Will griffirr's stuff be in v.1.3?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 10th Apr 2007 18:31
yes, for sure :p

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 21st May 2007 18:34
@ Freddix,

v.1.3 eagerly awaited...

in the meantime, I am still stuck on what if anything I need to do with the res files when making my plugin - do I have to create my own res files? or do I simply include all the pre-created ones? or some of them? pls help on this...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 22nd May 2007 13:35
I'm preparing the build 1.3 today

Here are the news:
FIXES:
- Fixed problem with PurePLUGIN Version/Revision informations
- Added a "DBPro_eXtras" directory with extra functions to use for specific purposes.
- crashes when using eXtends plugin support are now fixed (PurePLUGIN.DLL 1.2d+)
IMPROVEMENTS:
- Added Griffirrs 's PPFixer tool.
- Upgraded help to use PureBASIC Compiler capability to handle .RC files instead of Resource Hacker.
- Upgraded help to use PPFixer tool instead of XVI Hex Editor.
- EZ Rotate Basic.

It will be available to registered users at later tomorrow (or today if I get enough free time to release it today)

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 22nd May 2007 15:18
@Freddix,

Great news. Referring back to my last post, could you explain res files a little more? Perhaps take a simple command like GetFreeMemblock and show what one would have to do to get it working as a plugin command - particularly what one would have to do in relation to res file(s) and rc files?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 22nd May 2007 15:47
in fact, I didn't deeply explained how the .RES files works because it exist a full tutorial (I did develop for TheGameCreators) that cover the entire subject. The tutorial is available here:
http://www.thegamecreators.com/data/newsletter/newsletter_issue_22.html#17

More to this, the file :
HELP\String Table Edition.html
give an explanation on how the resources files works.
(commands, functions, parameters type)

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 23rd May 2007 01:52
@ Freddix - nearly understanding the .res file -

isnt this the same thing that you in effect create with resource hacker for your new commands ie. isnt it just creating the single string table?

in other words, what difference is there between the .res file and the .rc file that griffirr is talking about? do you have to create a .res file with resource hacker for your new commands? or can you use griffirr's new rc file?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 23rd May 2007 02:33 Edited at: 23rd May 2007 02:34
the are no differencies between .RES and .RC except the file format... .RES are saved in a specific file format and .RC are simple text files.
You can use new .RC files instead of .RES ones. It's easier with PureBASIC 4 tu use .RC files.
because you can directly in the compiler options, add the .RC file.
With that, the PureBASIC will integrate the .RC file containing all string table you've putted in to create your TPC commands. Take also as a note that a .RC file can contain several string tables (regarding to the fact that each .RES file can contain only 1 string table)

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 23rd May 2007 11:07
Freddix,

Sorry about all those questions - finally the lightbulb goes on Thank you for perservering with me.

So I can do just the one .rc file for all my new commands? if that's so, wonderful!

I've downloaded v1.3 - but could you add a little here about the new image and bitmap data procedures - what sort of things can you do with them? - I ask because I spend days creating a lavish set of DBPro memblock functions on images and bitmaps which I was preparing myself to convert over to purebasic and turn into a plugin... maybe some of these new image/bitmap data commands will shortcut for me??

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 23rd May 2007 14:05
Theorically, GetBitmapData and GetImageData may allow faster access to Bitmap/Images structures/Datas
For the capabilities offered by these two commands ... I can't really state. I get the informations on how to use them only few days ago from Mike and, I wanted to make them available in PurePLUGIN to allow users to explore them :p
Of course, I will make tests on them too to know exactly the limitations we'll have with them but for now, if you want to know more about what you can do with these I think you may question Mike.J (TGC)
If I manage to make something interesting using these commands, I'll add a sample in the next PurePLUGIN release

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 23rd May 2007 14:37
@ Freddix - great, thx again,

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th May 2007 12:23
@ Freddix,

How would I go about creating a commands in Purebasic for pureplugin where there were optional additional fields ie.

instr(source text, searchtext [,optional start position][,optional case sensitive]

? would I create the same named procedure but with different numbers of fields? how would this work with the .rc?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 26th May 2007 22:05 Edited at: 26th May 2007 22:15
When you say "creating a commands in Purebasic for pureplugin" .. you mean in fact : "creating a commands in Purebasic for DarkBASIC Professional" ?

If it's the case, then you'll have 3 procedureCDLL in your PureBASIC DLL with each a different name
in your string table, you'll have 3 commands. Each will call one of the ProcedureCDLL but, you can have the same DBPro commands for both 3 commands.
For example:

1. PureBASIC/PurePLUGIN DLL :


2. DLL String Table :


The DarkBASIC Professional user will then have 3 commands with various options


I hope this will help you

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th May 2007 00:06 Edited at: 27th May 2007 00:28
@ Freddix - that was it - spot on...

[edit]

Freddix - how do you go about encrypting your username and passcode in the dll without preventing the dll from working?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 27th May 2007 01:56 Edited at: 27th May 2007 01:58
when you compile your plugin, if you open the .DLL with an HEX editor, you'll see that you can find your user ID (it's not really difficult).

I recommand you to find an external way to make your user name/password crypted. and a small procedure that will uncrypt it in the Constructor or directly in the DBPro_Init.pb/InitDLLBase() to send to PurePLUGIN.DLL the uncrypted codes (to be sure the system will initialize correctly)
I can't provide a defined way to crypt/uncrypt codes because it may allow each PurePLUGIN registered user to uncrypt ID from other registered user when loading their released plugin... That's why I advice users to do that themselves.

I will try to do a small crypt/uncrypt sample to show how it can work ... I'll try to make a small algo based on id number you'll choose so ... someone will need to know the number you've entered to uncrypt your ID ... that may be a good "fast" way to crypt ids...

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th May 2007 02:52 Edited at: 27th May 2007 03:30
@ Freddix - the latter suggestion sounds great...

My first few plugins are in the making...

I'm stumbling a bit on String Functions...

[question 1] could you post the code for say a ProcedureCDLL in PureBasic to take in three strings, add them together and output a result of the three strings added together - that's all I need to take it from there... thanks...

p.s. think the above thread will hopefully help a lot of people like me get to grips with PurePlugin - keep it comin!

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th May 2007 03:21 Edited at: 27th May 2007 09:47
@Freddix,

[question 2] Also, would this Procedure CDLL code be OK for later Max$ and Min$ functions in DBPro:-



and...

[question 3] would the stringtable bit (in a stringtable in the .rc file) be:-



?

If not, how should it be done?

[question 4] What about finding Max and Min of two floats - would the ProcedureCDLL within Purebasic be:-


?

[question 5] what would the stringtable bits be for the Min and Max float functions? this?:-


?

[question 6] am I understanding the stringtables correctly - if I had a function taking in say one float, one integer and one string (in that order) and outputting one string would it be - 5, "Imaginary Function[%SFLS%ImaginaryFunction%" ? ie. with the outputted string at the start of the %SFLS% ?

[question 7] do the functions as described in the stringtable(s) in the rc file have to be put down in the same order that they appear in the .pb file code?

[question 8] is there a practical or actual limit to the number of commands and functions I could put in single .dll?

[question 9] if I wanted my functions and commands to have access to some global data, where in the main or 'yourprocedure' .pb file code would it be placed? in the main constructor part? or could it go anywhere in the 'yourprocedure' .pb code?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 27th May 2007 12:59 Edited at: 28th May 2007 00:51
[Question 2]
You've forgot something.
When you send back a STRING to DarkBASIC Professional, you must handle something called *OLDSTRING* ... I don't know why ... but Mike.J said "it's the way the compiler work" so, we must do this ... Oldstring is always the 1st parameter you have in your Procedure but, OldString does not appear in the string table.


For your question inside the ProcedureCDLL, the answer is quite simple. When requesting/sending a string from/to DarkBASIC Professional, you'll receive/send a POINTER to a string stored in memory. that's why you use =PeekS( Pointer.l ) because the vfalue you receive directly contain the memory adress.
When requesting/sending a float from/to DarkBASIC Professional, you'll receive a value that is the FLOAT itself (not a pointer) but, the FLOAT is CASTED as Integer so, you'll have to cast it as float again ( = PeekF( @Value.l ) so, you'll have to read the memory where the value is stored so you use the @

Otherwise, the command seem ok.

[Question 3]
It seem to be ok too
As I said upper, OldString does not appear in the string table.

[Question 4]
It seem to be ok ... I haven't checked what the function must do, but in syntax, all seem ok.

[Question 5]
Seem to be ok too

[Question 6]
The ouput is always the first parameter to appear in the String table. The input ones will follow it

[Question 7]
No. There is no need to put them in the same order than they appear in the DLL. DarkBASIC Professional will check itself to find them in the DLL

[Question 8]
I don't know ... XQuadEidtor contain no less than 25x16 commands ... so it must be a large number ...

[Question 9]
plz be more precise.

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th May 2007 21:25 Edited at: 27th May 2007 22:57
@ Freddix,

As ever, merci.

what is that b and that /b in your code?

Re: [question 2] do I need to do an oldstring for each string I am putting in to my function...? Do you just need the one OldString no matter how many strings are being passed IN to the procedure??? it is just there because it has to be? it does nothing?

[question 9] - I am envisaging something like a background global array with say placenames or so scores which functions can have access to and alter - but outside of individual procedures in purebasic .pb...? or another would be as Cash Curtis in thread above was envisaging a global counter recording say the last free object/mesh/matrix or whatever returned by a get free object/mesh/matrix function - external to the individual procedureCDLLs - where would you put it?

[new - question 10] - I've just (thankfully) had Spooky and IanM redirect me to some useful code to allow me to Get a Font Directory...

if result.s gives the font directory and there is no input string but the output (the location of the font directory) is a string is it... ProcedureCDLL GETFONTDIR(OldString.l) - even though I'm not inputting any strings, just outputting a string(the font directory location)???

[new - question 11] - cant find the call dll and other dll command equivalents in the DB procedures... ?
I want to turn the following (or something similar) into ProcedureCDLLs within Purebasic and then into my dll:-



could this be done? Could I work around it with Open Library and CallCFunction commands in PureBasic?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 28th May 2007 00:57
@Duffer that was to put text in BOLD but apparently you can't use this inside CODE statements ...

[Question 2]
Only 1 old string.

[Question 9]
You can put your variable declaration everywhere in your DLL before the ProcedureCDLL that uses thems.
You can for example, create a .pb file used for all variables, include it in the main .DLL pb file before all other includes for your functions.

[Question 10]
Yes
You must handle OLDSTRING when you send back a string to DBPRO ... Even if your procedure does not need any parameters.

[Question 11]
If you want to manually open a DLL, it's better and faster to directly use the PureBASIC commands that do this job


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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 28th May 2007 01:31 Edited at: 28th May 2007 02:25
@ Freddix - thx again, getting somewhere further now...

[edit].... why the (result) in the above code? why the use of brackets?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 28th May 2007 13:25
because when you call a function... it can return a value but it's not all case. you can hae :
Result = CallCFunctionFast( *FunctionPTR [,Parameter1 [, Parameter2...]])
Or:
CallCFunctionFast( *FunctionPTR [,Parameter1 [, Parameter2...]])

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 29th May 2007 01:36
@Freddix,

So long as they 'make sense' in Purebasic terms, can one of my ProcedureCDLLs use another one? eg. could one use within it say ProcedureCDLL.1 GetFreeMemblock() - something like that without the bizarro OldString?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 29th May 2007 02:38 Edited at: 29th May 2007 02:40
Yes of course,
It's really useful when you make same commands with a number of parameters that differ:

For example :



But don't forget that each procedureCDLL that will send a string to dbpro must also receive the oldstring.

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 4th Jun 2007 18:42
@Freddix,

Quote: "
If it's the case, then you'll have 3 procedureCDLL in your PureBASIC DLL with each a different name
in your string table, you'll have 3 commands. Each will call one of the ProcedureCDLL but, you can have the same DBPro commands for both 3 commands.
For example:

1. PureBASIC/PurePLUGIN DLL :
+ Code Snippet
ProcedureCDLL MyTest( Arg1.l )
...
EndProcedure
ProcedureCDLL MyTest2( Arg1.l, Arg2.l )
...
EndProcedure
ProcedureCDLL MyTest3( Arg1.l, Arg2.l, Arg3.l )
...
EndProcedure


2. DLL String Table :
+ Code Snippet
1, "My Command%L%Mytest%Arg1"
1, "My Command%LL%Mytest2%Arg1, Arg2"
1, "My Command%LLL%Mytest3%Arg1, Arg2, Arg3"


The DarkBASIC Professional user will then have 3 commands with various options
+ Code Snippet
My Command ARG1
My Command ARG1, ARG2
My Command ARG1, ARG2, ARG3
"


Could I still do it this way if say the Comnand in DBPro was Max() but this 'rested' on several procedures in PureBasic not with one, two or three integers but say either two integers, two strings or two floats - ie create a single DBPro Commands to return the max of two values whether they be integers, floats or strings?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 4th Jun 2007 19:32
I did never tried to do this... so, I don't know if DarkBASIC Professional will understand this or not.
You'll have to try

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 4th Jun 2007 21:32
@ Freddix - will do - and will report back...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 8th Jun 2007 11:15
@ Freddix - which directory should I compile my PureBasic dll in? Does it need to be in the DBPro directory>? Where?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 8th Jun 2007 19:49
no need
where you want

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
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Jun 2007 00:59
@ Freddix - thanks

Doing the .rc file now...

However, Griffir suggests the following format:-

whereas you suggest this structure (which is different) in your v.1.3 helpfile:-


which is the correct format for the .rc file?

should I be using the commas or not?
should I be using the BEGIN,END or the {,}?

presuming it is still commands 1-15 then 16-32 etc...?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 9th Jun 2007 01:11
no need for BEGIN and END
PureBASIC work perfectly with simply "STRINGTABLE" to say that what follow is a string table
and the string table is limited by { ... }
All what is between { } are the stringtable content

I didn't tried BEGIN / END by I think that if
Griffir say it work, it may then work ...

After, if both options work, it's up to you to choose what you prefer

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-05-18 19:35:44
Your offset time is: 2024-05-18 19:35:44