Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Support

Pages: [1] 2 3 ... 58
1
What's New / SBIDE
« on: May 29, 2021, 03:17:33 am »
I'm adding the core extension module FUNCTION/SUB syntax helpers to SBIDE's syntax tip help. After entering a keyword or extension function name and a ( the syntax tool tip will display. As you enter arguments the tool tip will move to the next argument. Once I completed the SBIDE enhancements I will post it here. I will include the updated SBIDE in the next Inno install build.

Hot Keys

ctrl-f - find/replace
ctrl-g - goto line
ctrl-z - undo
ctrl-y - redo

F2     - set breakpoint (runtime only)
F5     - go
F7     - single step
F8     - step over
F9     - step out


2
What's New / Re: ScriptBasic Core Windows 32 bit - Embedding
« on: May 25, 2021, 11:27:04 pm »
Here is my Hello World for ScriptBasic embedding. I typically IMPORT the script resources I need for the project as a source string for ScriptBasic to run.

Code: C
  1. // gcc for_embed.c -I C:\\sbgcc\\source ..\\lib\\libscriba.dll -lpthread -o for_embed
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <getopt.h>
  7. #include "scriba.h"
  8.  
  9. int main (int argc, char** argv)
  10. {
  11.   pSbProgram pProgram;
  12.   char src[] = "FOR i = 1 TO 5\nPRINT i,\"\\n\"\nNEXT\n";
  13.  
  14.   pProgram = scriba_new(malloc,free);
  15.   scriba_SetFileName(pProgram, "none");
  16.   scriba_LoadProgramString(pProgram, src, strlen(src));
  17.   scriba_Run(pProgram, "");
  18.  
  19.   scriba_destroy(pProgram);
  20.  
  21.   return(0);
  22. }  
  23.  


C:\sb_build\examples>gcc for_embed.c -I C:\\sbgcc\\source ..\\lib\\libscriba.dll -lpthread -o for_embed

C:\sb_build\examples>for_embed
1
2
3
4
5

C:\sb_build\examples>


3
What's New / Re: ScriptBasic Core Windows 32 bit - SQLite
« on: May 25, 2021, 10:29:58 pm »
This is an example of using the SQLite extension module.

Code: Script BASIC
  1. IMPORT sqlite.sbi
  2.  
  3. db = sqlite::open("sqlite_demo.db")
  4.  
  5. sqlite::execute(db,"create table demo (someval integer, sometxt text);")
  6. sqlite::execute(db,"insert into demo values (123,'hello');")
  7. sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")
  8. sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")
  9.  
  10. stmt = sqlite::query(db,"SELECT * FROM demo")
  11. WHILE sqlite::row(stmt) = sqlite::SQLITE3_ROW
  12.   IF sqlite::fetchhash(stmt, column) THEN
  13.     PRINT column{"someval"},"\t-\t",column{"sometxt"},"\n"
  14.   END IF
  15. WEND
  16.  
  17. sqlite::close(db)
  18.  


C:\sb_build\examples>sbc sqlite_demo.sb
123     -       hello
234     -       cruel
345     -       world

C:\sb_build\examples>


4
This example creates a synchronous thread with the main program running a FOR/NEXT loop in unison with its thread.

sbt_main.sb
Code: Script BASIC
  1. ' SBT Main
  2.  
  3. IMPORT mt.sbi
  4. IMPORT sbt.sbi
  5.  
  6. SB_ThreadStart("sbt_thread.sb", "","C:/Windows/SCRIBA.INI")
  7.  
  8. FOR x = 1 TO 10
  9.   PRINT "M:",x,"\n"
  10.   sb_msSleep(20)
  11. NEXT
  12.  
  13. SB_msSleep(1000)
  14.  
  15. PRINT "Thread ",mt::GetVariable("thread_status"),"\n"
  16.  

sbt_thread.sb
Code: Script BASIC
  1. ' SBT Main
  2.  
  3. IMPORT mt.sbi
  4. IMPORT sbt.sbi
  5.  
  6. SB_ThreadStart("sbt_thread.sb", "","C:/Windows/SCRIBA.INI")
  7.  
  8. FOR x = 1 TO 10
  9.   PRINT "M:",x,"\n"
  10.   sb_msSleep(20)
  11. NEXT
  12.  
  13. SB_msSleep(1000)
  14.  
  15. PRINT "Thread ",mt::GetVariable("thread_status"),"\n"
  16.  


C:\sb_build\examples>sbc sbt_main.sb
T:1
M:1
T:2
M:2
M:3
T:3
T:4
M:4
M:5
T:5
T:6
M:6
T:7
M:7
T:8
M:8
M:9
T:9
T:10
M:10
Thread Completed

C:\sb_build\examples>


5
This example creates a ScriptBasic asynchronous thread from a string of source code, sets / gets variables and calls a function.

Code: Script BASIC
  1. ' SBT - Create and call child process script as text source
  2.  
  3. IMPORT sbt.sbi
  4.  
  5. sb_code = """
  6. FUNCTION prtvars(a, b, c)
  7.  PRINT a,"\\n"
  8.  PRINT FORMAT("%g\\n", b)
  9.  PRINT c,"\\n"
  10.  prtvars = "Function Return"
  11. END FUNCTION
  12.  
  13. a = 0
  14. b = 0
  15. c = ""
  16. """
  17.  
  18. sb = SB_New()
  19. SB_Configure sb, "C:/Windows/SCRIBA.INI"
  20. SB_Loadstr sb, sb_code
  21. SB_NoRun sb
  22. ' Call function before running script
  23. funcrtn = SB_CallSubArgs(sb,"main::prtvars", 123, 1.23, "One, Two, Three")
  24. PRINT funcrtn,"\n"
  25. ' Run script initializing globals
  26. SB_Run sb, ""
  27. ' Assign variables values
  28. SB_SetInt sb, "main::a", 321
  29. SB_SetDbl sb, "main::b", 32.1
  30. SB_SetStr sb, "main::c", "Three,Two,One" & CHR(0)
  31. ' Call function again with variables assigned in the previous step
  32. SB_CallSubArgs sb, "main::prtvars", _
  33.           SB_GetVar(sb, "main::a"), _
  34.           SB_GetVar(sb, "main::b"), _
  35.           SB_GetVar(sb, "main::c")
  36. SB_Destroy sb
  37.  


C:\sb_build\examples>sbc sbt_demo.sb
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One

C:\sb_build\examples>


6
What's New / Re: ScriptBasic Core Windows 32 bit - ODBC
« on: May 25, 2021, 10:27:14 pm »
This example uses the ODBC extension module to get the customers from the Sage 100 ABC demo company.

Code: Script BASIC
  1. ' Sage 100 Customers - ABC Demo (ProvideX ODBC Driver)
  2.  
  3. IMPORT odbc.sbi
  4.  
  5. dbh = odbc::RealConnect("SOTAMAS90","","")
  6. odbc::Query(dbh,"SELECT * FROM AR_Customer")
  7.  
  8. WHILE odbc::FetchHash(dbh, column)
  9.   PRINT column{"CustomerNo"}," - ",column{"CustomerName"}," - ",column{"TelephoneNo"},"\n"
  10. WEND
  11.  
  12. odbc::Close(dbh)
  13.  


C:\sb_build\examples>sbc odbc_100.sb
ABF - American Business Futures - (414) 555-4787
ABS - ABS - Sage cloud for invoices - (949) 555-7814
AVNET - Avnet Processing Corp - (414) 555-2635
BRESLIN - Breslin Parts Supply - (414) 555-9654
HILLSB - Hillsboro Service Center - (414) 555-6599
INACTIV - Inactive Customer **INACTIVE** - (414) 555--8747
INTMEX - Int. Cust with Mexican Address Name expanded to 50 - +52 646 177 1466
MAVRK - Maverick Papers - (312) 861-1200
RSSUPPL - R & S Supply Corp. - (414) 555-5587
SHEPARD - Shepard Motorworks - (414) 555-6544
ALLENAP - Allen's Appliance Repair - (714) 555-3121
AMERCON - American Concrete Service - (714) 555-2134
ATOZ - A To Z Carpet Supply - (714) 555-2231
AUTOCR - Autocraft Accessories - (714) 555-0101
BAYPYRO - Bay Pyrotronics Corp. - (415) 555-9654
CAPRI - Capri Sailing Ships - (714) 555-4421
CUSTOM - Custom Craft Products - (714) 555-7848
GREALAR - Greater Alarm Company - (714) 555-5531
JELLCO - Jellco Packing - (714) 555-9451
ORANGE - Orange Door & Window Co. - (714) 555-7823

C:\sb_build\examples>


7
What's New / Re: ScriptBasic Core Windows 32 bit - FFI
« on: May 25, 2021, 10:26:23 pm »
This example uses the DYC extension module to make a dynamic FFI call to the Windows MessageBox API function.

Code: Script BASIC
  1. ' DYC - FFI Extension
  2.  
  3. DECLARE SUB DLL ALIAS "dyc" LIB "dyc"
  4.  
  5. PRINT DLL("ms,i,USER32.DLL,MessageBox,PZZL", 0, "Message Text", "Title", 3)
  6.  
  7. '""" Return Values
  8. Titlebar Exit = 2
  9. Yes = 6
  10. No = 7
  11. Cancel = 2
  12. """
  13.  


C:\sb_build\examples>sbc dyc_msgbox.sb
6
C:\sb_build\examples>


8
What's New / Re: ScriptBasic Core Windows 32 bit - cURL
« on: May 25, 2021, 10:25:19 pm »
This example uses the cURL extension module to download the text version of the War and Peace book.

Code: Script BASIC
  1. 'cURL Example - Download War & Peace book as text file.
  2.  
  3. IMPORT curl.sbi
  4.  
  5. ch = curl::init()
  6. curl::option(ch, "URL", "http://www.textfiles.com/etext/FICTION/warpeace.txt")
  7. curl::option(ch, "FILE", "warpeace.txt")
  8. curl::perform(ch)
  9. PRINT curl::info(ch, "EFFECTIVE_URL"),"\n"
  10. PRINT FORMAT("Data downloaded: %0.0f bytes.\n", curl::info(ch, "SIZE_DOWNLOAD"))
  11. PRINT FORMAT("Total download time: %0.3f sec.\n", curl::info(ch, "TOTAL_TIME"))
  12. PRINT FORMAT("Average download speed: %0.3f kbyte/sec.\n", curl::info(ch, "SPEED_DOWNLOAD") / 1024)
  13. curl::finish(ch)
  14.  


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>


9
What's New / Re: ScriptBasic Core Windows 32 bit - COM Excel
« on: May 25, 2021, 10:24:16 pm »
This example populates an Excel spreadsheet using the COM/OLE Automation extension module.

Code: Script BASIC
  1. ' Excel Example
  2.  
  3. IMPORT com.sbi
  4.  
  5. oExcelApp = COM::CREATE(:SET, "Excel.Application")
  6. oWorkBook = COM::CBN(oExcelApp, "Workbooks", :GET)
  7. oExcelWorkbook = COM::CBN(oWorkBook, "Add", :CALL)
  8. oExcelSheet = COM::CBN(oExcelWorkbook, "Worksheets", :GET, 1)
  9. FOR i=1 TO 10
  10.   FOR j=1 TO 10
  11.     oCell = COM::CBN(oExcelSheet, "Cells", :GET, i, j)
  12.     COM::CBN(oCell, "Value", :LET, "test-" & i & "-" & j)
  13.     COM::RELEASE(oCell)
  14.   NEXT
  15. NEXT
  16. COM::CBN(oExcelWorkbook, "SaveAs", :CALL, CURDIR() & "\\sbexcel.xlsx")
  17. COM::CBN(oExcelWorkbook, "Close", :CALL)
  18. COM::CBN(oExcelApp, "Quit", :CALL)
  19.  
  20. PRINT "Spreadsheet Created\n"
  21.  
  22. COM::RELEASE(oExcelSheet)
  23. COM::RELEASE(oExcelWorkbook)
  24. COM::RELEASE(oWorkBook)
  25. COM::RELEASE(oExcelApp)
  26.  

10
What's New / Re: ScriptBasic Core Windows 32 bit - Sage 100 BOI
« on: May 25, 2021, 10:22:13 pm »
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
  1. ' Sage 100 - First Customer - Print Selected Columns
  2.  
  3. IMPORT com.sbi
  4.  
  5. oscript = COM::CREATE(:SET, "ProvideX.Script")
  6. COM::CBN(oScript, "Init", :CALL, "C:\\Sage\\Sage 100 Standard\\MAS90\\Home")
  7.  
  8. osession = COM::CBN(oscript, "NewObject", :SET, "SY_Session")
  9. COM::CBN(osession, "nSetUser", :CALL, "UserID", "Password")
  10. COM::CBN(osession, "nsetcompany", :CALL, "ABC")
  11. COM::CBN(osession, "nSetDate", :CALL, "A/R", "20210520")
  12. COM::CBN(osession, "nSetModule", :CALL, "A/R")
  13. ocust = COM::CBN(oscript, "NewObject", :SET, "AR_Customer_svc", osession)
  14. COM::CBN(ocust, "nMoveFirst", :CALL)
  15. CustomerNo = COM::CBN(ocust, "sCustomerNo", :GET)
  16. CustomerName = COM::CBN(ocust, "sCustomerName", :GET)
  17. City = COM::CBN(ocust, "sCity", :GET)
  18. State = COM::CBN(ocust, "sState", :GET)
  19. TelephoneNo = COM::CBN(ocust, "sTelephoneNo", :GET)
  20. COM::CBN(ocust, "DropObject", :CALL)
  21. COM::CBN(osession, "DropObject", :CALL)
  22. COM::RELEASE(oscript)
  23.  
  24. PRINT "Customer:  ", CustomerNo, "  ", CustomerName, "  ", City, "  ", State, "  ", TelephoneNo, "\n"
  25.  


C:\sb_build\examples>sbc com_100.sb
Customer:  ABF  American Business Futures  Milwaukee  WI  (414) 555-4787

C:\sb_build\examples>


11
What's New / Re: ScriptBasic Core Windows 32 bit - CIO
« on: May 25, 2021, 10:08:22 pm »
The cio_colors.sb program uses the CIO extension module for console mode screen attributes.

Code: Script BASIC
  1. ' Display all the possible console character colors
  2.  
  3. IMPORT cio.sbi
  4.  
  5. cio::SetColor FWhite
  6. cio::cls
  7. cio::SetTitle "Testing console colors"
  8. FOR i = 1 TO 255
  9.   cio::gotoxy +(i \ 16) * 4 , +(i % 16) * 2
  10.   cio::gotoxy( (i \ 16) * 4 , +(i % 16) * 2 )
  11.   cio::gotoxy (i \ 16) * 4 , +(i % 16) * 2
  12.   cio::SetColor (i)
  13.   j = i
  14.   IF i < 100 THEN j = "0" & j
  15.   PRINT j
  16. NEXT i
  17. cio::SetColor FWhite
  18. cio::SetCursor 0
  19. i = cio::getch()
  20. cio::cls
  21.  

12
What's New / ScriptBasic Core Windows 32 bit Install
« on: May 25, 2021, 10:07:09 pm »
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

ScriptBasic User Guide

ScriptBasic SandBox Repository

ScriptBasic Download Attached

13
Documentation / ScriptBasic Support
« on: January 02, 2021, 11:09:09 am »


The ScriptBasic (MIT Common License) open source project is maintained by John Spikowski. (Peter Verhas - original author) I'm a senior developer offering affordable programming support for ScriptBasic, Sage 100 and Quickbooks accounting packages.


EMAIL: support@scriptbasic.org
LINKEDIN: John Spikowski
PHONE/TEXT: 360-941-0452
LOCATION: Anacortes, WA USA


14
What's New / Re: ScriptBasic - Raspberry Pi
« on: April 01, 2019, 05:20:21 am »
Attached are the extension modules and dependencies need for the bbc and gfx extension modules. These extensions only work with the DEB install at this time.

One must install the SDL 1.2 and SDL_gfx 1.2 runtime libraries.

sudo apt-get install libsdl1.2debian-1.2.15+dfsg1-4+rpt2
sudo apt-get install libsdl-gfx1.2-5-2.0.25-5

BBC
1. unzip the bbc.zip file in a temp directory
2. sudo cp bbc.so /usr/local/lib/scriba/
3. sudo cp bbc.bas /usr/local/include/scriba/
4. sudo cp libbbc.so /usr/lib/


SDL_gfx
1. unzip the gfx.zip file in a temp directory
2. sudo cp gfx.so /usr/local/lib/scriba/
3. sudo cp gfx.bas /usr/local/include/scriba/

Use the ScriptBasic example code posted in this thread to test your installation.

15
What's New / Re: ScriptBasic - Raspberry Pi
« on: April 01, 2019, 05:19:03 am »
This shows some of the SDL_gfx graphic primitives.

Code: Script BASIC
  1. ' SDL_gfx Demo
  2.  
  3. IMPORT gfx.bas
  4.  
  5. screen = gfx::Window(700, 600, "ScriptBasic GFX Demo - Raspberry Pi")
  6. gfx::pixelRGBA(screen, 10, 15, 255, 255, 255, 255)
  7. gfx::lineRGBA(screen, 20, 10, 70, 90, 255, 0, 0, 255)
  8. gfx::trigonRGBA(screen, 500, 50, 550, 200, 600, 150, 0, 255, 255, 255)
  9. gfx::filledTrigonRGBA(screen, 200, 200, 300, 50, 400, 200, 0, 0, 255, 255)
  10. gfx::rectangleRGBA(screen, 10, 300, 100, 380, 0, 255, 0, 255)
  11. gfx::boxRGBA(screen, 210, 76, 325, 300, 255, 0, 0, 150)
  12. gfx::ellipseRGBA(screen, 600, 400, 50, 90, 255, 255, 0, 200)
  13. gfx::filledEllipseRGBA(screen, 600, 400, 25, 150, 0, 255, 0, 255)
  14. x[0] = 350
  15. x[1] = 275
  16. x[2] = 300
  17. x[3] = 325
  18. x[4] = 350
  19. x[5] = 400
  20. y[0] = 325
  21. y[1] = 325
  22. y[2] = 390
  23. y[3] = 390
  24. y[4] = 375
  25. gfx::polygonRGBA(screen, x, y, 6, 255, 255, 255, 155)
  26. s[0] = 400
  27. s[1] = 450
  28. s[2] = 450
  29. s[3] = 425
  30. s[4] = 300
  31. t[0] = 400
  32. t[1] = 410
  33. t[2] = 450
  34. t[3] = 425
  35. t[4] = 500
  36. gfx::filledPolygonRGBA(screen, s, t, 5, 255, 0, 255, 155)
  37. gfx::Update
  38. WHILE gfx::KeyName(1) <> "+escape"
  39. WEND
  40. gfx::Close
  41.  

Pages: [1] 2 3 ... 58