Используя скриптовый язык Gentee http://www.gentee.ru/ можно добавить возможность использования скриптов в ваших программах. Для движка нужна только одна Gentee.dll
#Compile Exe
#Dim All
#Include "Win32Api.Inc"
Type sgeinit
gSize As Dword
gflags As Dword
message As Dword
gPrint As Dword
gExport As Dword
End Type
Type sbcode
dat As Dword
sze As Dword
rsv As Byte
End Type
Declare Function ge_init Lib "Gentee.dll" Alias "ge_init" (ByVal Struct As Dword) As Dword
Declare Function ge_load Lib "Gentee.dll" Alias "ge_load" (ByVal bytecode As Dword, ByVal loadflag As Dword, ByVal args As Dword) As Dword
Declare Function ge_getid Lib "Gentee.dll" Alias "ge_getid" (ByVal gName As Dword) As Dword
Declare Function ge_call CDecl Lib "Gentee.dll" Alias "ge_call" (ByVal id As Dword, ByVal result As Dword, ByVal p1 As Dword, ByVal p2 As Dword, ByVal p3 As Dword, ByVal p4 As Dword ) As Dword
Declare Function ge_compile Lib "Gentee.dll" Alias "ge_compile" (ByVal filename As Dword, ByVal fileout As Dword, ByVal sb As Dword, ByVal cflag As Dword, ByVal args As Dword) As Dword
Declare Function ge_deinit Lib "Gentee.dll" Alias "ge_deinit" (ByVal Hwnd As Dword) As Dword
Function MsgBoxPB(ByRef P As Asciiz * 255, ByRef P2 As Asciiz * 255) As Long
Function= MsgBox (p,,p2)
End Function
Function InputBoxPB (ByRef TXT As Asciiz * 512) As String
Function=InputBox$(TXT)
End Function
Function exporttogentee (ByRef nFunct As Asciiz * 255 ) As Dword
Select Case As Const$ nFunct
Case "MsgBoxPB"
Function=CodePtr(MsgBoxPB)
Case "InputBoxPB"
Function=CodePtr( InputBoxPB)
End Select
End Function
Function WinMain ( ByVal hInstance As Dword, _
ByVal hPrevInst As Dword, _
ByVal lpszCmdLine As Asciiz Ptr, _
ByVal nCmdShow As Long ) As Long
Dim ST As sgeinit
Dim Source As String
Dim cstr As String
Dim ByteCode As SBCODE
Dim BytecodePath As String
Dim Code As String
ST.gSize=20
ST.gflags=4
ST.message=CodePtr(exporttogentee)
ST.gExport=CodePtr(exporttogentee)
Call ge_init(VarPtr(ST))
Source = "<Test> import """" {uint MsgBoxPB(uint, uint)" & $CrLf
Source = Source & "uint InputBoxPB(uint)} " & $CrLf
Source = Source & "func start< main > {" & $CrLf
Source = Source & "str txt" & $CrLf
Source = Source & "txt.copy(InputBoxPB(""Hello PB!"".ptr()))" & $CrLf
Source = Source & "MsgBoxPB (txt.ptr(),""Gentee"".ptr())" & $CrLf
Source = Source & "}"
BytecodePath="bytecode.bin"
Call ge_compile (StrPtr(Source),StrPtr(BytecodePath), VarPtr(ByteCode),0,0)
Code=Peek$(ByteCode.dat,ByteCode.sze)
Call ge_load (StrPtr(Code), 7, 0)
Call ge_deinit(hInstance)
ExitProcess (0)
End Function
Ответить
|