Charles,
Can you show me an updated version of how I can embed ScriptBasic using OxygenBasic? (scriba shell replacement) Here is the code you submitted for the SB embedding code challenge done back in Sept. of 2009.
'--------------------------------
'EMBEDDING SCRIPT BASIC IN OXYGEN
'================================
#basic
#file "o2embeds.exe"
Dim pProgram,iError
Function newmem CDECL (ByVal le As Long) As Long Export
'print `newmem`
Function=news le
End Function
Function freemem CDECL (ByVal p As Long) Export
'print `freemem`
frees p
End Function
'-----------
'WINDOWS API
'===========
declare function AllocConsole lib "kernel32.dll" alias "AllocConsole" () as long
declare function SetConsoleTitle lib "kernel32.dll" alias "SetConsoleTitleA" (lpConsoleTitle as asciiz) as long
declare function GetStdHandle lib "kernel32.dll" alias "GetStdHandle" (byval nStdHandle AS dword) as long
declare function WriteConsole lib "kernel32.dll" alias "WriteConsoleA" (byval hConsoleOutput as dword, lpBuffer as asciiz, BYVAL nNumberOfCharsToWrite AS LONG, lpNumberOfCharsWritten AS LONG, byval lpReserved as long) as long
%STD_INPUT_HANDLE = -10
%STD_OUTPUT_HANDLE = -11
%STD_ERROR_HANDLE = -12
AllocConsole
'-----------------
'CONSOLE INTERFACE
'=================
'
'DIM consIn AS LONG,consOut AS LONG,consErr AS LONG
'ConsIn =GetStdHandle (%STD_INPUT_HANDLE)
'ConsOut=GetStdHandle (%STD_OUTPUT_HANDLE)
'ConsErr=GetStdHandle (%STD_ERROR_HANDLE)
'
'DIM bufout AS ASCIIZ(8000)
'DIM buflen AS LONG
'DIM bufrit AS LONG
' BOOL WINAPI WriteConsole(
' __in HANDLE hConsoleOutput,
' __in const VOID *lpBuffer,
' __in DWORD nNumberOfCharsToWrite,
' __out LPDWORD lpNumberOfCharsWritten,
' __reserved LPVOID lpReserved
' );
' BOOL WINAPI SetConsoleTitle(
' __in LPCTSTR lpConsoleTitle
'
' );
SetConsoleTitle "Oxygen ScriptBasic Embedding Test"
'TEST CONSOLE OUTPUT
'
'bufout="Hello"
' buflen=LEN(bufout) 'buggy with static strings
'buflen=5
'WriteConsole ConsOut,bufout,buflen,bufrit,0
'------------------------------------
'EARLY BINDING (no access to console)
'------------------------------------
'
'%o2Basic=1
'#include "scriba.inc"
'------------------------
'LATE BINDING (LOW LEVEL)
'------------------------
dim sbl
sbl=loadlibrary "libscriba.dll"
bind sbl
(
scriba_new scriba_new
scriba_LoadConfiguration scriba_LoadConfiguration
scriba_SetFileName scriba_SetFileName
scriba_LoadSourceProgram scriba_LoadSourceProgram
scriba_Run scriba_Run
scriba_destroy scriba_destroy
)
pProgram=scriba_new &newmem, &freemem
scriba_LoadConfiguration(pProgram,"c:\scriptbasic\bin\scriba.conf")
scriba_SetFileName(pProgram,"E02.bas")
scriba_LoadSourceProgram(pProgram)
iError=scriba_Run(pProgram,"Hello")
scriba_destroy(pProgram)
freelibrary sbl
'PRINT "ok: " hex(iError) " " hex(pProgram)