Karbon wrote:Could someone point me in the right direction to find some information about making a userlib in PB?
I have a few DLLs that I'd like to wrap up and have access without having to use Callfuntion() and friends if possible...
The library SDK is the only current source of information I think. Do you really need to write a user library or do you just need to get access to the DLL functions?
If you want to code the library (insead of importing the DLL) and create your own commands then you only really need to write a .desc file (which tells PureBasic what commands and things there are), keep to the naming convention, and play nicely with the global variables which you have access to. As long as your compiler / assembler / whatever can create a standard format of library (.lib) file (sometimes called static library or import library) then it should be possibleto write a PureLibrary with it.
Functions in your code which are to be used as commands in PureBasic should have their names start with "PB_".
Commands which have multiple forms (for example, for ones which have optional parameters) should have the second and additional functions end with the number of which version of the command it is, i.e.:
PB_MyCommand <- First set of parameters
PB_MyCommand2 <- second
PB_MyCommand3 <- third
The number which you give them is the order in which the parameter descriptions appear in the .desc file.
There are some global variables which you use to interact with the debugger.
Your debug code must be a function for each command function (this is called before your command function). It must have the same parameters as the command function, but does not return anything. Its name must be the same as the command function, with "_DEBUG" on the end. In the above case of multiple optional parameters, the debug functions would be:
PB_MyCommand_DEBUG
PB_MyCommand2_DEBUG
PB_MyCommand3_DEBUG
If you just want to get access to the DLL functions then you can use the DLLImport tool. All you need to do for this is to write a text file (with a .pbl extension) and in there you need to put the library name on the first line and then the names of the functions, a space, then the number of parameters for that function. Each function is on it's own line. Example:
Code: Select all
library_with_cool_stuff.dll
first_function 0
count_chicken 4
That means that the DLL which will be used is named "library_with_cool_stuff.dll". There are two functions being imported, one called "first_function" which has no parameters. The second function is called "count_chicken" and has 4 parameters.
You then need to run the DLLImport tool where you tell it the directory where your .pbl file is located and where you want to install the library that is created - normally PureBasic\PureLibraries\UserLibraries.