- Aug
- 2,263
- 108
I have been using Delphi 2.0 to write my plugins, and it has been going okay.
I’ve been taking some of my more useful Pascal routines, and putting them into plugin form.
I also have quite a few routines written in PowerBASIC, and would like to incorporate them into plugin form.
Instead of translating the PowerBASIC code to Delphi 2.0, I was looking at doing one of two things.
The first would be to leave the PowerBASIC routines in the present PowerBASIC DLL, and then just call them from the Delphi 2.0 plugin.
The second, which would also be a learning opportunity, would be to convert my PowerBASIC DLL into a plugin.
So, I gave it a go, and have written a test plugin, thus;
I am getting a “Relational operator expected” at;
piInfo.pszDLL = ("PBDemo")
I have tried changing it to;
piInfo.pszDLL = UCODE$("PBDemo")
but same problem. I thought it was something to do with conversion to Unicode, but I am not sure.
I just need to get the “GetPluginInfo” working, if that is indeed where my problem is.
The PowerBASIC Manual is online at http://www.powerbasic.com/support/help/pbwin/index.htm
If the SDK had contained only the C++ example, I probably would never have even considered writing a plugin, but since it had an example for Delphi, I had no problem putting my own functions into the template, and it works quite well.
Adding a plugin template for PowerBASIC to the SDK may also entice others to consider writing their own plugins.
Joe
I’ve been taking some of my more useful Pascal routines, and putting them into plugin form.
I also have quite a few routines written in PowerBASIC, and would like to incorporate them into plugin form.
Instead of translating the PowerBASIC code to Delphi 2.0, I was looking at doing one of two things.
The first would be to leave the PowerBASIC routines in the present PowerBASIC DLL, and then just call them from the Delphi 2.0 plugin.
The second, which would also be a learning opportunity, would be to convert my PowerBASIC DLL into a plugin.
So, I gave it a go, and have written a test plugin, thus;
Code:
#COMPILE DLL
#DIM ALL
#INCLUDE "WIN32API.INC"
TYPE PLUGININFO
pszDll AS ASCIIZ PTR ' name of the DLL
pszAuthor AS ASCIIZ PTR ' author's name
pszEmail AS ASCIIZ PTR ' author's email
pszWWW AS ASCIIZ PTR ' author's web page
pszDescription AS ASCIIZ PTR ' (brief) description of plugin
pszFunctions AS ASCIIZ PTR ' comma-delimited list of functions in the
' plugin (leading _ for internal vars, @ for
' var funcs, * for keystroke function,
' otherwise it's a command)
nMajor AS LONG ' plugin's major version #
nMinor AS LONG ' plugin's minor version #
nBuild AS LONG ' plugin's build #
hModule AS LONG ' module handle
pszModule AS ASCIIZ PTR ' module name
END TYPE
TYPE KEYINFO
nKey AS LONG ' key entered
nHomeRow AS LONG ' start row
nHomeColumn AS LONG ' start column
nRow AS LONG ' current row in window
nColumn AS LONG ' current column in window
pszLine AS ASCIIZ PTR ' command line
pszCurrent AS ASCIIZ PTR ' pointer to position in line
fRedraw AS LONG ' if != 0, redraw the line
END TYPE
FUNCTION InitializePlugin ALIAS "InitializePlugin" () EXPORT AS BYTE
InitializePlugin = 0
END FUNCTION
FUNCTION ShutdownPlugin ALIAS "ShutdownPlugin" (EndProcess AS BYTE) EXPORT AS BYTE
ShutdownPlugin = 0
END FUNCTION
FUNCTION GetPluginInfo ALIAS "GetPluginInfo" (BYVAL piInfo AS PLUGININFO) EXPORT AS LONG
piInfo.pszDLL = UCODE$("PBDemo")
piInfo.pszAuthor = "Joe Caverly"
piInfo.pszEmail = "[email protected]"
piInfo.pszWWW = ""
piInfo.pszDescription = "A demonstration Plugin for 4NT/TCC, written with PowerBASIC"
piInfo.pszFunctions = "@TIMES2"
piInfo.nMajor = 1
piInfo.nMinor = 0
piInfo.nBuild = 1
GetPluginInfo = piInfo
END FUNCTION
FUNCTION Times2 ALIAS "Times2" (BYVAL x AS LONG) EXPORT AS LONG
Times2 = x * 2
END FUNCTION
FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, BYVAL lReason AS LONG, BYVAL lReserved AS LONG) AS LONG
SELECT CASE AS LONG lReason
CASE %DLL_PROCESS_ATTACH
' This DLL has been mapped into the memory context of
' the calling program, and can be initialized as required.
' Here we return a non-zero LIBMAIN result to indicate success.
LIBMAIN = 1
EXIT FUNCTION
CASE %DLL_PROCESS_DETACH
' This DLL is about to be unloaded
EXIT FUNCTION
CASE %DLL_THREAD_ATTACH
' A [New] thread is starting (see THREADID)
EXIT FUNCTION
CASE %DLL_THREAD_DETACH
' This thread is closing (see THREADID)
EXIT FUNCTION
END SELECT
END FUNCTION
piInfo.pszDLL = ("PBDemo")
I have tried changing it to;
piInfo.pszDLL = UCODE$("PBDemo")
but same problem. I thought it was something to do with conversion to Unicode, but I am not sure.
I just need to get the “GetPluginInfo” working, if that is indeed where my problem is.
The PowerBASIC Manual is online at http://www.powerbasic.com/support/help/pbwin/index.htm
If the SDK had contained only the C++ example, I probably would never have even considered writing a plugin, but since it had an example for Delphi, I had no problem putting my own functions into the template, and it works quite well.
Adding a plugin template for PowerBASIC to the SDK may also entice others to consider writing their own plugins.
Joe