This solution looks like I can only communicate with one variable at  a time.  

  To be honest, this is a kludge and you need a better way for the host and MY-BASIC to share its variables. I would like to be able to do something like the Perl extension module for SB.
DECLARE SUB pl_Init ALIAS "pl_Init" LIB "sbperl"
DECLARE SUB pl_Eval ALIAS "pl_Eval" LIB "sbperl"
DECLARE SUB pl_GetInt ALIAS "pl_GetInt" LIB "sbperl"
DECLARE SUB pl_GetDbl ALIAS "pl_GetDbl" LIB "sbperl"
DECLARE SUB pl_GetStr ALIAS "pl_GetStr" LIB "sbperl"
DECLARE SUB pl_Destroy ALIAS "pl_Destroy" LIB "sbperl"
 
pl_Init
 
pl_code = """
sub Average{
   # get total number of arguments passed.
   $n = scalar(@_);
   $sum = 0;
 
   foreach $item (@_){
      $sum += $item;
   }
   $average = $sum / $n;
 
   return $average;
}
"""
pl_Eval pl_code
pl_Eval "$num = Average(10, 20, 30);"
PRINT pl_GetInt("num"),"\n"
 
pl_Destroy
 
jrs@laptop:~/sb/sb22/test$ scriba perlfunc.sb
20
jrs@laptop:~/sb/sb22/test$ 
Here is an example of embedding Script BASIC in BaCon and using the SQLite3 extension module and passing the resulting record set back to BaCon.
PRAGMA OPTIONS -I/home/jrs/sb/source
PRAGMA LDFLAGS scriba pthread
PRAGMA INCLUDE scriba.h getopt.h
PROTO scriba_destroy
DECLARE pProgram TYPE pSbProgram
DECLARE pVariable TYPE pSbData
pProgram = scriba_new(malloc,free)
ok = scriba_LoadConfiguration(pProgram,"/etc/scriba/basic.conf")
ok = scriba_SetFileName(pProgram, "E05.sb")
ok = scriba_LoadSourceProgram(pProgram)
ok = scriba_Run(pProgram,"")
vsn = scriba_LookupVariableByName(pProgram, "main::dbstr")
ok = scriba_GetVariable(pProgram, vsn, &pVariable)
dbstr$ = pVariable[0].v.s
SPLIT dbstr$ BY "|" TO row$ SIZE cnt
FOR x = 0 TO cnt-1
PRINT row$[x]
NEXT x
jrs@laptop:~/BaCon/B29$ ./bacon sqlext.bac
Converting 'sqlext.bac'... done.
Compiling 'sqlext.bac'... done.
Program 'sqlext' ready.
jrs@laptop:~/BaCon/B29$ ./sqlext
123-hello
234-cruel
345-world
jrs@laptop:~/BaCon/B29$ 
E05.sbIMPORT sqlite.bas
 
db = sqlite::open("testsql")
 
sqlite::execute(db,"CREATE TABLE demo (someval integer, sometxt text);")
sqlite::execute(db,"INSERT INTO demo VALUES (123,'hello');")
sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")
sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")
 
stmt = sqlite::query(db,"SELECT * FROM demo")
 
WHILE (sqlite::row(stmt) = sqlite::SQLITE3_ROW)
  IF sqlite::fetchhash(stmt,column) THEN
    dbstr &= column{"someval"} & "-" & column{"sometxt"} & "|"
  END IF
WEND
 
sqlite::close(db)