Hi all,
I use PowerBasic Compiler in order to create NeoBook Plugins.
NeoBook is a Rapid Application Builder based on Delphi 7
You can download NeoBook 5.6 trial at this link:
http://www.neosoftware.com/software/nbw.exe
NeoBook provides a SDK in order to create external services. This services can be written in Delphi, C++ or Powerbasic.
You can download the SDK of NeoBook at this link:
http://www.neosoftware.com/software/nbwpluginsdk.zip
You can use this help in order to install any plugin:
http://www.neosoftware.com/nbw1.html#install
In fact, I had created some plugins that works fine.
But, I don't know how to connect the Edit component dialogs with the IDE of NeoBook in order to complete the command line.
Here is a sample of a plugin. This sample format a number and return the result as "ae_resultado" NeoBook variable.
#COMPILE DLL "NeoFormat"
#DIM ALL
#INCLUDE "WIN32API.INC"
$PLUGIN_TITLE = "NeoFormat 1.0.2"
$PLUGIN_AUTHOR = "David de Argentina"
$PLUGIN_INFO = "Number Formatter"
'****************** NeoBook Interface Functions DO NOT MODIFY *****************
'*
'* Action Command Parameter Types...
'*
%ACTIONPARAM_NONE = 0
%ACTIONPARAM_ALPHA = 1 ' May contain alpha, numeric, punctuation, etc.
%ACTIONPARAM_ALPHASP = 2 ' Contains aplha text that can be spell checked.
%ACTIONPARAM_NUMERIC = 3 ' Must be numeric value 0..9
%ACTIONPARAM_MIXED = 4 ' May be either numeric or alpha. May contain math expression
%ACTIONPARAM_FILENAME = 5 ' Parameter is a file name
%ACTIONPARAM_VARIABLE = 6 ' Parameter is a variable name
%ACTIONPARAM_DATAFILE = 7 ' Parameter is data file - if not a variable then should be localized
%MaxActionParams = 10 ' Maximum number of parameters per action
%NULL = 0
DECLARE SUB AddActionProcType(BYVAL IDNum AS LONG, BYREF zName AS ASCIIZ, BYREF Hint AS ASCIIZ, BYREF Params AS ASCIIZ)
DECLARE SUB AddFileProcType(BYREF s AS ASCIIZ, BYVAL AddFlag AS LONG)
DECLARE SUB GetVarProcType(BYREF VarName AS ASCIIZ, BYREF Value AS ASCIIZ)
DECLARE SUB SetVarProcType(BYREF VarName AS ASCIIZ, BYREF Value AS ASCIIZ)
DECLARE SUB PlayActionProcType(BYREF s AS ASCIIZ)
DECLARE FUNCTION InterfaceProcType(BYVAL InterfaceID AS LONG, BYREF zData AS ASCIIZ) AS LONG
DECLARE SUB dllHandlerProcType(BYVAL Reason AS LONG)
SUB FreeStr(BYREF S AS DWORD)
IF S <> %NULL THEN GlobalFree S
S = %NULL
END SUB
SUB SetStr(BYREF Dest AS DWORD, BYVAL Source AS STRING)
FreeStr Dest
IF LEN(Source) THEN
Dest = GlobalAlloc(%GPTR, LEN(Source) + 1)
POKE$ Dest, Source
END IF
END SUB
GLOBAL nbGetVar AS DWORD
GLOBAL nbSetVar AS DWORD
GLOBAL nbPlayAction AS DWORD
GLOBAL nbInterface AS DWORD
GLOBAL nbAddFile AS DWORD
GLOBAL nbAddAction AS DWORD
GLOBAL nbWinHandle AS DWORD
GLOBAL RetValue$
GLOBAL firstime AS STRING
GLOBAL vuelta AS STRING
'---------------------------------
SUB xnbAddAction(BYVAL IDNum AS LONG, zName AS ASCIIZ, zHint AS ASCIIZ, Params AS ASCIIZ, BYVAL NumParams AS BYTE)
ASM push eax
ASM xor eax,eax
ASM mov al, NumParams
ASM push eax
ASM push eax
CALL DWORD nbAddAction USING AddActionProcType(IDNum, zName, zHint, Params)
ASM pop eax
END SUB
SUB SetVariable(BYVAL Variable$,BYVAL vuelta$)
CALL DWORD nbSetVar USING SetVarProcType("ae_resultado", BYCOPY vuelta$)
END SUB
FUNCTION PBMAIN()
END FUNCTION
FUNCTION ae_formatnum (a AS ASCIIZ) EXPORT AS STRING
LOCAL p1 AS CUX, p2 AS LONG, p3 AS LONG, p4 AS LONG, p5 AS STRING
LOCAL formato AS STRING, result AS STRING, cp3 AS STRING,cp4 AS STRING
LOCAL aux AS STRING
P1=VAL(PARSE$(a,"|",1)) 'number
P2=VAL(PARSE$(a,"|",2)) 'len
p3=VAL(PARSE$(a,"|",3)) 'decimals
P4=VAL(PARSE$(a,"|",4)) 'millards separator
P5=PARSE$(a,"|",5) 'Fill character
' P4 could be:
' 1 for No Separator
' 2 for US Style (99,999.99)
' 3 for European Style (99.999,99)
IF p4 > 1 THEN
cp4 = ","
ELSE
cp4 = ""
END IF
IF p5 = "" THEN
p5 = " "
END IF
result = SPACE$(p2)
cp3 = REPEAT$(p3,"0")
if p3 > 0 then
formato = "* #"+cp4+"."+cp3
else
formato = "* #"+cp4
end if
RSET result = FORMAT$( p1, CHR$(32)+formato+CHR$(32) )
aux = RIGHT$(result,1)
IF aux = " " THEN
result = LEFT$(result,LEN(result)-1)
END IF
REPLACE " " WITH p5 IN result
IF p4 = 3 THEN
REPLACE "." WITH "|" IN result
REPLACE "," WITH "." IN result
REPLACE "|" WITH "," IN result
END IF
vuelta$ = result
setvariable "ae_resultado", vuelta$
END FUNCTION
'********** NeoBook Plug-In Functions that Must be Customized by You **********
FUNCTION nbEditAction ALIAS "_nbEditAction@8" (BYVAL IDNum AS LONG, Params AS ASCIIZ) EXPORT AS BYTE
SELECT CASE IDNum
CASE 1: FUNCTION = %True
CASE ELSE: FUNCTION = %FALSE
END SELECT
END FUNCTION
FUNCTION nbExecAction ALIAS "_nbExecAction@8" (BYVAL IDNum AS LONG, BYREF Par$) EXPORT AS BYTE
DIM x AS ASCIIZ PTR
x = STRPTR(Par$)
SELECT CASE IDNum
CASE 1: AE_FormatNum BYCOPY @x : FUNCTION = %True
CASE ELSE: FUNCTION = %FALSE
END SELECT
END FUNCTION
SUB nbInitPlugIn ALIAS "_nbInitPlugIn@16" (BYVAL WinHandle AS DWORD, _
BYREF PlugInTitle AS DWORD, _
BYREF PlugInPublisher AS DWORD, _
BYREF PlugInHint AS DWORD) EXPORT
nbWinHandle = WinHandle
SetStr PlugInTitle, $PLUGIN_TITLE
SetStr PlugInPublisher, $PLUGIN_AUTHOR
SetStr PlugInHint, $PLUGIN_INFO
END SUB
SUB nbRegisterScriptProcessor ALIAS "_nbRegisterScriptProcessor@4" (BYVAL PlayActionProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbPlayAction = PlayActionProc
'****************************************************************************
END SUB
SUB nbMessage ALIAS "_nbMessage@8" (BYVAL MsgCode AS LONG, BYVAL Reserved AS LONG) EXPORT
SELECT CASE MsgCode
CASE 01: ' Don't care
CASE 02: ' Don't care
CASE 03: ' Don't care
CASE 04: ' Don't care
CASE 05: ' Don't care
CASE 06: ' Don't care
CASE 07: ' Don't care
CASE 08: ' Don't care
CASE 09: ' Don't care
CASE 10: ' Don't care
END SELECT
END SUB
SUB nbRegisterInterfaceAccess ALIAS "_nbRegisterInterfaceAccess@4" (BYVAL InterfaceProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbInterface = InterfaceProc
'****************************************************************************
END SUB
FUNCTION VerifyRegCode(byval Code AS ASCIIZ PTR) AS LONG
FUNCTION = %True
END FUNCTION
FUNCTION GetRegCode(BYREF CodeStr AS ASCIIZ) AS LONG
CodeStr = "ABC123"
FUNCTION = %True
END FUNCTION
FUNCTION nbVerifyLicense(BYREF Code AS ASCIIZ) AS BYTE
DIM CodeStr AS ASCIIZ * 256
IF LEN(Code) = 0 THEN ' empty parameter
IF GetRegCode(CodeStr) THEN
SetStr VARPTR(Code), CodeStr
FUNCTION = %TRUE
END IF
ELSE
FUNCTION = VerifyRegCode(VARPTR(Code))
END IF
END FUNCTION
SUB nbRegisterPlugIn ALIAS "_nbRegisterPlugIn@16" (BYVAL AddActionProc AS DWORD, _
BYVAL AddFileProc AS DWORD, _
BYVAL VarGetFunc AS DWORD, _
BYVAL VarSetFunc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbGetVar = VarGetFunc
nbSetVar = VarSetFunc
nbAddAction = AddActionProc
nbAddFile = AddFileProc
'****************************************************************************
'******************* Enter your Plug-In's actions below *******************
xnbAddAction 1, "AE_FormatNum ", "Set Format to a number: return value on [ae_resultado]" _
+ CHR$(13,10) + "AE_FormatNum " + CHR$(34)+ "[num]|[lenght]|[decimals]|[milliards]|[character_to_fill]"+CHR$(34), "ACTIONPARAM_ALPHA", 1
END SUB
FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, _
BYVAL Reason AS LONG, _
BYVAL Reserved AS LONG) AS LONG
IF (Reason = %DLL_PROCESS_DETACH) THEN
END IF
FUNCTION = %True
END FUNCTION
If you compile this code ( I use PB7) , you will obtain a .DLL file. Rename this to .NBP file and add this to the NeoBook IDE clicking the Options Menu -> Install Plugins. NeoBook will assume the "AE_FormatNum" function as native NeoBook Function.
How do I do in order to create a Edit dialog and pass the function parameters ( in this case, the number, len, decimal places, milliards and dot separators and character to fill to the NeoBook action editor ? There are good samples for Delphi and C++ to do this.. but I can't do work my addapted version..
Could any help me ?
Thanks in advance,
Greetings from Buenos Aires,
David de Argentina
I forgot this:
The final NeoBook command line at the Actions Editor must look like this:
AE_FormatNum "[number]|[length]|[decimals]|[milliards]|[fill_char]"
Example:
AE_FormatNum "12345678|12|2|2|*"
Thanks again,
David de Argentina