You can embed a script without having to run it using the scriba_NoRun call. You're able to call functions/subs and access/set global variables. (embeddable function library)
iembed
' ScriptBasic self embedding demo
INCLUDE "iembed.sbh"
pProgram = DLL("sb_new")
_DLL "scriba_LoadConfiguration", pProgram, "/etc/scriba/basic.conf"
_DLL "scriba_SetFileName", pProgram, "E02.sb"
_DLL "scriba_LoadSourceProgram", pProgram
_DLL "scriba_NoRun", pProgram
v = _DLL("scriba_LookupVariableByName", pProgram, "main::a")
_DLL "scriba_SetVariable", pProgram, v, SBT_LONG, 500
f = _DLL("scriba_LookupFunctionByName", pProgram, "main::vprint")
_DLL "scriba_Call", pProgram, f
_DLL "scriba_destroy", pProgram
E02.sb
SUB vprint
PRINT "Variable 'a' = ",a,"\n"
END SUB
a = 0
jrs@Laptop:~/SB/test$ scriba iembed
Variable 'a' = 500
jrs@Laptop:~/SB/test$
iembed.sbh
DECLARE SUB DLL ALIAS "_idll" LIB "iDLL-Server"
DECLARE SUB REQUIRE ALIAS "_idll_require" LIB "iDLL-Server"
DECLARE SUB DEFINE ALIAS "_idll_define" LIB "iDLL-Server"
REQUIRE "libiDLL.so"
DEFINE "sb_new NONE POINTER 0"
DEFINE "scriba_LoadConfiguration NONE INT 2 POINTER STRING"
DEFINE "scriba_SetFileName NONE INT 2 POINTER STRING"
DEFINE "scriba_LoadSourceProgram NONE INT 1 POINTER"
DEFINE "scriba_Run NONE INT 2 POINTER STRING"
DEFINE "scriba_NoRun NONE INT 1 POINTER"
DEFINE "scriba_LookupVariableByName NONE LONG 2 POINTER STRING"
DEFINE "scriba_SetVariable NONE INT 4 POINTER LONG INT LONG"
DEFINE "scriba_LookupFunctionByName NONE LONG 2 POINTER STRING"
DEFINE "scriba_Call NONE INT 2 POINTER LONG"
DEFINE "scriba_destroy NONE NONE 1 POINTER"
CONST SBT_LONG = 2
FUNCTION _DLL(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
LOCAL arg_str
arg_str = STR(a0) & " " & STR(a1) & " " & STR(a2) & " " & STR(a3) & " " & STR(a4) & " " & STR(a5) & " " & STR(a6) & " " & STR(a7) & " " & STR(a8) & " " & STR(a9)
_DLL = DLL(arg_str)
END FUNCTION