91
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on March 24, 2024, 07:32:42 PM »Jack,
Here is an example of calling the libscriba.dll using the SBT extension module.
Output
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One
Looking at the SBT extension module C source may be helpful as well.
Before Charles moved his hosting preference to Theo's forum I was testing embedding libscriba.dll with OxygenBasic.
O2 SB Embed
Here is an example of calling the libscriba.dll using the SBT extension module.
Code: ScriptBasic
- ' SBT Demo
- IMPORT sbt.sbi
- sb_code = """
- FUNCTION prtvars(a, b, c)
- PRINT a,"\\n"
- PRINT FORMAT("%g\\n", b)
- PRINT c,"\\n"
- prtvars = "Function Return"
- END FUNCTION
- a = 0
- b = 0
- c = ""
- """
- sb = SB_New()
- SB_Configure sb, "C:/Windows/SCRIBA.INI"
- SB_Loadstr sb, sb_code
- SB_NoRun sb
- ' Call function before running script
- funcrtn = SB_CallSubArgs(sb,"main::prtvars", 123, 1.23, "One, Two, Three")
- PRINT funcrtn,"\n"
- ' Run script initializing globals
- SB_Run sb, ""
- ' Assign variables values
- SB_SetInt sb, "main::a", 321
- SB_SetDbl sb, "main::b", 32.1
- SB_SetStr sb, "main::c", "Three,Two,One" & CHR(0)
- ' Call function again with variables assigned in the previous step
- SB_CallSubArgs sb, "main::prtvars", _
- SB_GetVar(sb, "main::a"), _
- SB_GetVar(sb, "main::b"), _
- SB_GetVar(sb, "main::c")
- SB_Destroy sb
Output
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One
Looking at the SBT extension module C source may be helpful as well.
Before Charles moved his hosting preference to Theo's forum I was testing embedding libscriba.dll with OxygenBasic.
O2 SB Embed