David
21-10-2013, 10:18
Hi all,
This code works like a charm into PowerBasic
#COMPILE DLL "ThinBasic_NeoSDK"
#INCLUDE "Win32Api.inc"
#INCLUDE "ThinCore.inc"
'---------------------------------------------------
GLOBAL nbGetVar AS DWORD
GLOBAL nbSetVar AS DWORD
GLOBAL nbPlayAction AS DWORD
GLOBAL nbInterface AS DWORD
GLOBAL nbWinHandle AS DWORD
GLOBAL zData AS ASCIIZ * 64
GLOBAL zz AS ASCIIZ PTR
GLOBAL dwData AS DWORD
'---------------------------------------------------
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 Exec_NeoSDK_SetVariable(BYVAL Variable$,BYVAL vuelta$)
CALL DWORD nbSetVar USING SetVarProcType(BYCOPY variable$, BYCOPY vuelta$)
END SUB
'---------------------------------------------------
SUB Exec_NeoSDK_PlayScript(BYVAL Script$)
CALL DWORD nbPlayAction USING PlayActionProcType(BYCOPY Script$)
END SUB
'---------------------------------------------------
FUNCTION Exec_NeoSDK_GetVariable (VarName AS STRING) AS STRING
LOCAL sName AS ASCIIZ * 40
LOCAL sptr AS ASCIIZ PTR
zData = ""
sName = VarName
CALL DWORD nbGetVar USING GetVarProcType(BYREF sName, BYREF zData)
sPtr = VARPTR(zData)
sName = @@sptr
FUNCTION = Sname
END FUNCTION
'---------------------------------------------------
FUNCTION Exec_NeoSDK_GetObjectHandle (sname AS STRING) AS LONG
LOCAL sptr AS ASCIIZ PTR
sPtr = VARPTR(sname)
zData = @sptr
CALL DWORD nbInterface USING InterfaceProcType (BYVAL 7, BYREF zData)
zz = VARPTR(zData)
FUNCTION = VAL(@@zz)
END FUNCTION
'---------------------------------------------------
FUNCTION Exec_NeoSDK_Get_nbInterface (ID AS LONG, texto AS STRING) AS STRING
LOCAL sptr AS ASCIIZ PTR
sPtr = VARPTR(texto)
zData = @sptr
CALL DWORD nbInterface USING InterfaceProcType (BYVAL ID, BYREF zData)
zz = VARPTR(zData)
FUNCTION = @@zz
END FUNCTION
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
SUB nbRegisterScriptProcessor ALIAS "_nbRegisterScriptProcessor@4" (BYVAL PlayActionProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbPlayAction = PlayActionProc
'****************************************************************************
END SUB
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
SUB nbRegisterInterfaceAccess ALIAS "_nbRegisterInterfaceAccess@4" (BYVAL InterfaceProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbInterface = InterfaceProc
'****************************************************************************
END SUB
'----------------------------------------------------------------------------
FUNCTION LoadLocalSymbols ALIAS "LoadLocalSymbols" (OPTIONAL BYVAL sPath AS STRING) EXPORT AS LONG
' This function is automatically called by thinCore whenever this DLL is loaded.
' This function MUST be present in every external DLL you want to use
' with thinBasic
' Use this function to initialize every variable you need and for loading the
' new symbol (read Keyword) you have created.
'----------------------------------------------------------------------------
thinBasic_LoadSymbol "NeoSDK_PlayScript" , %thinBasic_ReturnNone , CODEPTR(Exec_NeoSDK_PlayScript) , %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "NeoSDK_SetVariable", %thinBasic_ReturnNone , CODEPTR(Exec_NeoSDK_SetVariable), %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "NeoSDK_GetVariable", %thinBasic_ReturnString, CODEPTR(Exec_NeoSDK_GetVariable), %thinBasic_ForceOverWrite
END FUNCTION
'----------------------------------------------------------------------------
FUNCTION UnLoadLocalSymbols ALIAS "UnLoadLocalSymbols" () EXPORT AS LONG
' This function is automatically called by thinCore whenever this DLL is unloaded.
' This function CAN be present but it is not necessary. If present, this function
' will be executed by thinBasic core when module will be released.
' Use this function to perform uninitialize process, if needed.
'----------------------------------------------------------------------------
FUNCTION = 0&
END FUNCTION
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, _
BYVAL Reason AS LONG, _
BYVAL Reserved AS LONG) AS LONG
SELECT CASE Reason
CASE %DLL_PROCESS_ATTACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_PROCESS_DETACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_THREAD_ATTACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_THREAD_DETACH
FUNCTION = %True
EXIT FUNCTION
END SELECT
END FUNCTION
I know the syntax is not thinBasic friendly...
But problem is in this line:
CALL DWORD nbPlayAction USING PlayActionProcType(BYCOPY Script$)
Are there any way to migrate this code to thinBasic style ?
Thanks in advance,
David
This code works like a charm into PowerBasic
#COMPILE DLL "ThinBasic_NeoSDK"
#INCLUDE "Win32Api.inc"
#INCLUDE "ThinCore.inc"
'---------------------------------------------------
GLOBAL nbGetVar AS DWORD
GLOBAL nbSetVar AS DWORD
GLOBAL nbPlayAction AS DWORD
GLOBAL nbInterface AS DWORD
GLOBAL nbWinHandle AS DWORD
GLOBAL zData AS ASCIIZ * 64
GLOBAL zz AS ASCIIZ PTR
GLOBAL dwData AS DWORD
'---------------------------------------------------
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 Exec_NeoSDK_SetVariable(BYVAL Variable$,BYVAL vuelta$)
CALL DWORD nbSetVar USING SetVarProcType(BYCOPY variable$, BYCOPY vuelta$)
END SUB
'---------------------------------------------------
SUB Exec_NeoSDK_PlayScript(BYVAL Script$)
CALL DWORD nbPlayAction USING PlayActionProcType(BYCOPY Script$)
END SUB
'---------------------------------------------------
FUNCTION Exec_NeoSDK_GetVariable (VarName AS STRING) AS STRING
LOCAL sName AS ASCIIZ * 40
LOCAL sptr AS ASCIIZ PTR
zData = ""
sName = VarName
CALL DWORD nbGetVar USING GetVarProcType(BYREF sName, BYREF zData)
sPtr = VARPTR(zData)
sName = @@sptr
FUNCTION = Sname
END FUNCTION
'---------------------------------------------------
FUNCTION Exec_NeoSDK_GetObjectHandle (sname AS STRING) AS LONG
LOCAL sptr AS ASCIIZ PTR
sPtr = VARPTR(sname)
zData = @sptr
CALL DWORD nbInterface USING InterfaceProcType (BYVAL 7, BYREF zData)
zz = VARPTR(zData)
FUNCTION = VAL(@@zz)
END FUNCTION
'---------------------------------------------------
FUNCTION Exec_NeoSDK_Get_nbInterface (ID AS LONG, texto AS STRING) AS STRING
LOCAL sptr AS ASCIIZ PTR
sPtr = VARPTR(texto)
zData = @sptr
CALL DWORD nbInterface USING InterfaceProcType (BYVAL ID, BYREF zData)
zz = VARPTR(zData)
FUNCTION = @@zz
END FUNCTION
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
SUB nbRegisterScriptProcessor ALIAS "_nbRegisterScriptProcessor@4" (BYVAL PlayActionProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbPlayAction = PlayActionProc
'****************************************************************************
END SUB
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
SUB nbRegisterInterfaceAccess ALIAS "_nbRegisterInterfaceAccess@4" (BYVAL InterfaceProc AS DWORD) EXPORT
'***************************** Do Not MODIFY ********************************
nbInterface = InterfaceProc
'****************************************************************************
END SUB
'----------------------------------------------------------------------------
FUNCTION LoadLocalSymbols ALIAS "LoadLocalSymbols" (OPTIONAL BYVAL sPath AS STRING) EXPORT AS LONG
' This function is automatically called by thinCore whenever this DLL is loaded.
' This function MUST be present in every external DLL you want to use
' with thinBasic
' Use this function to initialize every variable you need and for loading the
' new symbol (read Keyword) you have created.
'----------------------------------------------------------------------------
thinBasic_LoadSymbol "NeoSDK_PlayScript" , %thinBasic_ReturnNone , CODEPTR(Exec_NeoSDK_PlayScript) , %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "NeoSDK_SetVariable", %thinBasic_ReturnNone , CODEPTR(Exec_NeoSDK_SetVariable), %thinBasic_ForceOverWrite
thinBasic_LoadSymbol "NeoSDK_GetVariable", %thinBasic_ReturnString, CODEPTR(Exec_NeoSDK_GetVariable), %thinBasic_ForceOverWrite
END FUNCTION
'----------------------------------------------------------------------------
FUNCTION UnLoadLocalSymbols ALIAS "UnLoadLocalSymbols" () EXPORT AS LONG
' This function is automatically called by thinCore whenever this DLL is unloaded.
' This function CAN be present but it is not necessary. If present, this function
' will be executed by thinBasic core when module will be released.
' Use this function to perform uninitialize process, if needed.
'----------------------------------------------------------------------------
FUNCTION = 0&
END FUNCTION
'*********************************************************
' ***** Following function may not be modificate ********
'*********************************************************
FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, _
BYVAL Reason AS LONG, _
BYVAL Reserved AS LONG) AS LONG
SELECT CASE Reason
CASE %DLL_PROCESS_ATTACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_PROCESS_DETACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_THREAD_ATTACH
FUNCTION = %True
EXIT FUNCTION
CASE %DLL_THREAD_DETACH
FUNCTION = %True
EXIT FUNCTION
END SELECT
END FUNCTION
I know the syntax is not thinBasic friendly...
But problem is in this line:
CALL DWORD nbPlayAction USING PlayActionProcType(BYCOPY Script$)
Are there any way to migrate this code to thinBasic style ?
Thanks in advance,
David