This is an example of embedding ScriptBasic in bc9.
' bc9 Basic Interpreter
#include <scriba.h>
#include <getopt.h>
Global pProgram as pSbProgram
pProgram = scriba_new(malloc,free)
scriba_LoadConfiguration(pProgram,"/etc/scriba/basic.conf")
scriba_SetFileName(pProgram, COMMAND$(1))
scriba_LoadSourceProgram(pProgram)
scriba_Run(pProgram,COMMAND$(2))
scriba_destroy(pProgram)
jrs@laptop:~/bcx9$ gcc ibc9.C -I/home/jrs/sb/source -lscriba -lpthread -o ibc9
ibc9.C: In function ‘int main(int, char**)’:
ibc9.C:169:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
jrs@laptop:~/bcx9$ ./ibc9 E01.sb JRS
(0): error &H44:The file can not be read.
Segmentation fault (core dumped) jrs@laptop:~/bcx9$
If I hard code the arguments and don't use the COMMAND$() option, I get warnings but at least it runs. I don't seem to have this issue with BaCon and embedding SB.
' bc9 Basic Interpreter
#include <scriba.h>
#include <getopt.h>
Global pProgram as pSbProgram
pProgram = scriba_new(malloc,free)
scriba_LoadConfiguration(pProgram,"/etc/scriba/basic.conf")
scriba_SetFileName(pProgram,"E01.sb")
scriba_LoadSourceProgram(pProgram)
scriba_Run(pProgram,"JRS")
scriba_destroy(pProgram)
jrs@laptop:~/bcx9$ gcc ibc9.C -I/home/jrs/sb/source -lscriba -lpthread -o ibc9
ibc9.C: In function ‘int main(int, char**)’:
ibc9.C:169:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
ibc9.C:170:37: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
ibc9.C:172:26: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
jrs@laptop:~/bcx9$ ./ibc9
ARG = JRS
1
2
3
4
5
6
7
8
9
10
jrs@laptop:~/bcx9$