Discussion Topics > Script BASIC
ScriptBasic Core Windows 32 bit Install
John Spikowski:
The attached ScriptBasic Windows install is a core distribution with the essential extension modules included. A User Guide is included as a Windows .CHM help file. The following posts to this thread are examples that are also included with the install program.
Core Extension Modules
[*] COM/OLE Automation
[*] cURL Library
[*] ODBC
[*] SQLite
[*] Dynamic FFI
[*] Asynchronous / Synchronous Threading
[/list]
ScriptBasic User Guide
ScriptBasic SandBox Repository
ScriptBasic Download Attached
John Spikowski:
The cio_colors.sb program uses the CIO extension module for console mode screen attributes.
--- Code: Script BASIC ---' Display all the possible console character colors IMPORT cio.sbi cio::SetColor FWhitecio::clscio::SetTitle "Testing console colors"FOR i = 1 TO 255 cio::gotoxy +(i \ 16) * 4 , +(i % 16) * 2 cio::gotoxy( (i \ 16) * 4 , +(i % 16) * 2 ) cio::gotoxy (i \ 16) * 4 , +(i % 16) * 2 cio::SetColor (i) j = i IF i < 100 THEN j = "0" & j PRINT jNEXT icio::SetColor FWhitecio::SetCursor 0i = cio::getch()cio::cls
John Spikowski:
This is an example of using the COM/OLE extension module with the Sage 100 accounting software getting the first Customer in the table.
--- Code: Script BASIC ---' Sage 100 - First Customer - Print Selected Columns IMPORT com.sbi oscript = COM::CREATE(:SET, "ProvideX.Script")COM::CBN(oScript, "Init", :CALL, "C:\\Sage\\Sage 100 Standard\\MAS90\\Home") osession = COM::CBN(oscript, "NewObject", :SET, "SY_Session")COM::CBN(osession, "nSetUser", :CALL, "UserID", "Password")COM::CBN(osession, "nsetcompany", :CALL, "ABC")COM::CBN(osession, "nSetDate", :CALL, "A/R", "20210520")COM::CBN(osession, "nSetModule", :CALL, "A/R")ocust = COM::CBN(oscript, "NewObject", :SET, "AR_Customer_svc", osession)COM::CBN(ocust, "nMoveFirst", :CALL)CustomerNo = COM::CBN(ocust, "sCustomerNo", :GET)CustomerName = COM::CBN(ocust, "sCustomerName", :GET)City = COM::CBN(ocust, "sCity", :GET)State = COM::CBN(ocust, "sState", :GET)TelephoneNo = COM::CBN(ocust, "sTelephoneNo", :GET)COM::CBN(ocust, "DropObject", :CALL)COM::CBN(osession, "DropObject", :CALL)COM::RELEASE(oscript) PRINT "Customer: ", CustomerNo, " ", CustomerName, " ", City, " ", State, " ", TelephoneNo, "\n"
C:\sb_build\examples>sbc com_100.sb
Customer: ABF American Business Futures Milwaukee WI (414) 555-4787
C:\sb_build\examples>
John Spikowski:
This example populates an Excel spreadsheet using the COM/OLE Automation extension module.
--- Code: Script BASIC ---' Excel Example IMPORT com.sbi oExcelApp = COM::CREATE(:SET, "Excel.Application")oWorkBook = COM::CBN(oExcelApp, "Workbooks", :GET)oExcelWorkbook = COM::CBN(oWorkBook, "Add", :CALL)oExcelSheet = COM::CBN(oExcelWorkbook, "Worksheets", :GET, 1)FOR i=1 TO 10 FOR j=1 TO 10 oCell = COM::CBN(oExcelSheet, "Cells", :GET, i, j) COM::CBN(oCell, "Value", :LET, "test-" & i & "-" & j) COM::RELEASE(oCell) NEXTNEXTCOM::CBN(oExcelWorkbook, "SaveAs", :CALL, CURDIR() & "\\sbexcel.xlsx")COM::CBN(oExcelWorkbook, "Close", :CALL)COM::CBN(oExcelApp, "Quit", :CALL) PRINT "Spreadsheet Created\n" COM::RELEASE(oExcelSheet)COM::RELEASE(oExcelWorkbook)COM::RELEASE(oWorkBook)COM::RELEASE(oExcelApp)
John Spikowski:
This example uses the cURL extension module to download the text version of the War and Peace book.
--- Code: Script BASIC ---'cURL Example - Download War & Peace book as text file. IMPORT curl.sbi ch = curl::init()curl::option(ch, "URL", "http://www.textfiles.com/etext/FICTION/warpeace.txt")curl::option(ch, "FILE", "warpeace.txt")curl::perform(ch)PRINT curl::info(ch, "EFFECTIVE_URL"),"\n"PRINT FORMAT("Data downloaded: %0.0f bytes.\n", curl::info(ch, "SIZE_DOWNLOAD"))PRINT FORMAT("Total download time: %0.3f sec.\n", curl::info(ch, "TOTAL_TIME"))PRINT FORMAT("Average download speed: %0.3f kbyte/sec.\n", curl::info(ch, "SPEED_DOWNLOAD") / 1024)curl::finish(ch)
C:\sb_build\examples>sbc curl_wget.sb
http://www.textfiles.com/etext/FICTION/warpeace.txt
Data downloaded: 4434670 bytes.
Total download time: 1.672 sec.
Average download speed: 2590.150 kbyte/sec.
C:\sb_build\examples>
Navigation
[0] Message Index
[#] Next page
Go to full version