(Note: more current information on Magsbot Plug-Ins can be found here.)

DLLs
(Dynamic Link Libraries)

To call DLLs from MB, first create a text file listing the names of the DLLs and the names of the functions in each DLL that you plan to call. (See the default list file, MBotDLLs.lst, for an example.) The DLLs in the list will be loaded when MB starts, and can then be called using the CALLDLL Action.

Functions written for use with MB should have the following form: (NOTE! These have changed since earlier versions of MB, in which DLL functions were assumed to use the stdcall format. MB now expects the cdecl format. I changed this to make it easier for people working with C to create DLLs for use by MB.)

In Pascal:

function MyFunction(pszInput: PChar): PChar; cdecl;

In C:

char *MyFunction (char *pszInput);

The pszInput argument is a null-terminated string that is passed from the CALLDLL Action's third parameter. The return string can contain an Action for MB to take, or be nil or empty.

You can download some example DLLs including source code here.

In earlier versions of Magsbot, the expression evaluation module of the program was contained in a DLL so people writing their own DLLs could call upon some of the same functions that Magsbot uses. However this created some serious limitations for me (notably strings had to be limited in length) so I since incorporated the evaluation module into the program. If there is any interest, I'll think about ways to allow DLLs to use the internal Magsbot functions, but for now you can still pass values from Magsbot in the pszInput string as shown above.



New in version 6.0:

The CALLDLLV works similarly to the CALLDLL command described above, except the third argument is a vlist instead of a string. The vlist can contain whatever values you wish to use in your DLL.

For DLLs that you intend to call using CALLDLLV, use this form for your procedures:

In Pascal:

procedure MyFunction(pt: Pointer); cdecl;

The ShareMemDLLExample files show how to get and put values from and to the vlist from within your DLL.

The MBPlugInExample files also show how to call the internal Magsbot functions from your DLL. (Version 6.0 a17 or later required.)