' O2 Sage BOI Example
% filename "sageboi.exe"
includepath "$/inc/"
include "RTL32.inc"
include "sbembed.inc"
#console
uses console
sys pProgram
sbData *arg
sbData *argr
string cr = chr(13,10)
int sb_call = 1
int sb_get = 2
int sb_let = 4
int sb_set = 8
string src = "IMPORT sbembed.sbi" + cr
pProgram = scriba_new(@newmem, @freemem)
scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
scriba_SetFileName(pProgram, "none")
scriba_LoadProgramString(pProgram, src, len(src))
scriba_Run(pProgram, "")
@argr = scriba_NewSbArgs(pProgram,"u")
sys fn1 = scriba_LookupFunctionByName(pProgram, "main::sb_create")
sys fn2 = scriba_LookupFunctionByName(pProgram, "main::sb_cbn")
sys fn3 = scriba_LookupFunctionByName(pProgram, "main::sb_release")
@arg = scriba_NewSbArgs(pProgram, "s", "ProvideX.Script")
scriba_CallArgEx(pProgram, fn1, argr, 1, arg)
sys oscript = argr.lng
@arg = scriba_NewSbArgs(pProgram, "i s i s", oscript, "Init", sb_call, "C:\Sage\Sage 100 Standard\MAS90\Home")
scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i s", oscript, "NewObject", sb_set, "SY_Session")
scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
sys osession = argr.lng
@arg = scriba_NewSbArgs(pProgram, "i s i s", osession, "nSetUser", sb_call, "js", "MY_PASSWORD")
scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i s", osession, "nsetcompany", sb_call, "ABC")
scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i s s", osession, "nSetDate", sb_call, "A/R", "20210331")
scriba_CallArgEx(pProgram, fn2, argr, 5, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i s i", oscript, "NewObject", sb_set, "AR_Customer_svc", osession)
scriba_CallArgEx(pProgram, fn2, argr, 5, arg)
sys ocust = argr.lng
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "nMoveFirst", sb_call)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCustomerNo", sb_get)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
string CustomerNo = argr.str
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCustomerName", sb_get)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
string CustomerName = argr.str
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCity", sb_get)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
string City = argr.str
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sState", sb_get)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
string State = argr.str
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sTelephoneNo", sb_get)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
string TelephoneNo = argr.str
@arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "DropObject", sb_call)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
@arg = scriba_NewSbArgs(pProgram, "i s i", osession, "DropObject", sb_call)
scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
@arg = scriba_NewSbArgs(pProgram, "i", oscript)
scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
print "Customer: " + CustomerNo " - " + CustomerName + " - " + City + " - " + State + " - " + TelephoneNo + cr
scriba_DestroySbArgs(pProgram, arg, 5)
scriba_DestroySbArgs(pProgram, argr, 1)
scriba_destroy(pProgram)