Hello,
Voici du code VBA (VB et portable facilement en VBnet) qui permet de charger FBSL.DLL et donc de jouer du code FBSL à la volée et de récupérer le retour :
Option Explicit
Private Declare Function FBSL_ExecuteScriptFile Lib "fbsl.dll" (ByVal szScriptfile$) As Long
Private Declare Function FBSL_GetReturnValue Lib "fbsl.dll" (ByVal pValue As Long, ByVal iType As Long) As Long
Private Declare Function FBSL_ExecuteScriptBuffer Lib "fbsl.dll" (ByVal ExternalBuffer$) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Const FBVT_STRING = 30
Const FBVT_INTEGER = 3
Const FBVT_DOUBLE = 5
Const FBVT_SINGLE = 4
Const ccode = "Return Right(""Hello"", 4) & 5 + 5 / 12 * PI"
Public Sub cmdRetCode()
If Trim$(ccode) <> "" Then
Dim i As Long
FBSL_ExecuteScriptBuffer ccode: DoEvents
'i = FBSL_GetReturnValue(1&, 0) ' Get the return type
i = FBSL_GetReturnValue(0&, FBVT_STRING)
Dim sSave As String, mStr As String
sSave = Space(i): mStr = Space(i)
FBSL_GetReturnValue StrPtr(sSave), FBVT_STRING
CopyMemory ByVal StrPtr(mStr), ByVal StrPtr(sSave), i
sSave = Left(StrConv(mStr, vbUnicode), i)
MsgBox "Returned value == " & sSave, vbApplicationModal, "RETURN CODE IS :"
End If
End Sub
Gérôme GUILLEMIN
Auteur du langage FBSL