Author Topic: ScriptBasic Windows 32 bit  (Read 7850 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
ScriptBasic Windows 32 bit
« on: September 18, 2022, 04:58:36 PM »
I'm putting together another Windows release which I'll post soon.

What's New
  • Recompile with TDM-GCC-32 10.3.0 release.
  • Print.c change to use %g for doubles rather than %le.
  • Updated JSON extension module by AIR.
  • New webext extension that features a JSON to SB arrays and back again functions..
  • Updated ODBC extension allowing column length of 4096 bytes and schema extension to generate SQL CREATE statements or return details about a column.
I'm not going to be including help or examples in the install. Those resources are available from the ScriptBasic forum.

Stay tuned ...

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic Windows 32 bit
« Reply #1 on: September 19, 2022, 08:12:27 PM »
Attached is the latest build / install of ScriptBasic Windows 32 bit. Let me know if you have questions or issues with an e-mail or join the forum to contribute. Here are a few examples to try out the extensions.

The install includes a GUI IDE / Debugger as well as console, Windows, DLL and web server versions of the interpreter.

COM/OLE - SAPI text to speech
Code: Script BASIC
  1. ' SAPI COM/OLE Example
  2.  
  3. IMPORT com.sbi
  4.  
  5. voice = COM::CREATE(:SET, "SAPI.SpVoice")
  6. COM::CBN(voice, "speak", :CALL, "Welcome to ScriptBasic")
  7.  
  8. COM::RELEASE(voice)
  9.  

Threads - This extension was a fork from the SBHTTPD application server. It gives console and Windows apps threading ability. It also allows using the MT module for sharing variables between the main process and threads.
Code: Script BASIC
  1. ' SBT Demo
  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.  


123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One


CIO Colors
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.  

cURL wget
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.  

SQLite
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.  

ODBC
Code: Script BASIC
  1. ' Sage 100 Customers - ABC Demo (ProvideX ODBC Driver)
  2.  
  3. IMPORT odbc.sbi
  4.  
  5. dbh = odbc::RealConnect("SAGE100","","")
  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.  

WebExt - JSON to SB Array - Dump - SB Array to JSON
Code: Script BASIC
  1. IMPORT webext.sbi
  2.  
  3. json = """{"QueryResponse":{"Customer":[{"Taxable":true,"BillAddr":{"Id":"99","Line1":"4581 Finch St.","Line2":"crows","City":"Bayshore","CountrySubDivisionCode":"CA","PostalCode":"94326"},"ShipAddr":{"Id":"99","Line1":"4581 Finch St.","Line2":"crows","City":"Bayshore","CountrySubDivisionCode":"CA","PostalCode":"94326"},"Job":false,"BillWithParent":false,"Balance":239,"BalanceWithJobs":239,"CurrencyRef":{"value":"USD","name":"United States Dollar"},"PreferredDeliveryMethod":"Print","IsProject":false,"ClientEntityId":"0","domain":"QBO","sparse":false,"Id":"1","SyncToken":"4","MetaData":{"CreateTime":"2022-06-07T16:48:43-07:00","LastUpdatedTime":"2022-07-15T23:48:50-07:00"},"GivenName":"Amy","FamilyName":"Lauterbach","FullyQualifiedName":"Amy's Bird Sanctuary","CompanyName":"Amy's Bird Sanctuary","DisplayName":"Amy's Bird Sanctuary","PrintOnCheckName":"Amy's Bird Sanctuary","Active":true,"V4IDPseudonym":"002098f70e10816c12487da5ddf91ce731f335","PrimaryPhone":{"FreeFormNumber":"(650) 555-3311"},"PrimaryEmailAddr":{"Address":"Birds@Intuit.com"},"DefaultTaxCodeRef":{"value":"2"}},{"Taxable":false,"BillAddr":{"Id":"3","Line1":"12 Ocean Dr.","City":"Half Moon Bay","CountrySubDivisionCode":"CA","PostalCode":"94213","Lat":"37.4307072","Long":"-122.4295234"},"Job":false,"BillWithParent":false,"Balance":85,"BalanceWithJobs":85,"CurrencyRef":{"value":"USD","name":"United States Dollar"},"PreferredDeliveryMethod":"Print","IsProject":false,"ClientEntityId":"0","domain":"QBO","sparse":false,"Id":"2","SyncToken":"0","MetaData":{"CreateTime":"2022-06-07T16:49:28-07:00","LastUpdatedTime":"2022-06-14T12:56:01-07:00"},"GivenName":"Bill","FamilyName":"Lucchini","FullyQualifiedName":"Bill's Windsurf Shop","CompanyName":"Bill's Windsurf Shop","DisplayName":"Bill's Windsurf Shop","PrintOnCheckName":"Bill's Windsurf Shop","Active":true,"V4IDPseudonym":"002098640048259088425d9597407a9d8707bf","PrimaryPhone":{"FreeFormNumber":"(415) 444-6538"},"PrimaryEmailAddr":{"Address":"Surf@Intuit.com"}},{"Taxable":false,"BillAddr":{"Id":"4","Line1":"65 Ocean Dr.","City":"Half Moon Bay","CountrySubDivisionCode":"CA","PostalCode":"94213","Lat":"37.4300318","Long":"-122.4336537"},"Job":false,"BillWithParent":false,"Balance":0,"BalanceWithJobs":0,"CurrencyRef":{"value":"USD","name":"United States Dollar"},"PreferredDeliveryMethod":"Print","IsProject":false,"ClientEntityId":"0","domain":"QBO","sparse":false,"Id":"3","SyncToken":"0","MetaData":{"CreateTime":"2022-06-07T16:51:22-07:00","LastUpdatedTime":"2022-06-15T12:59:21-07:00"},"GivenName":"Grace","FamilyName":"Pariente","FullyQualifiedName":"Cool Cars","CompanyName":"Cool Cars","DisplayName":"Cool Cars","PrintOnCheckName":"Cool Cars","Active":true,"V4IDPseudonym":"002098f42dce34ccf04f83aa5ffe4cc8202370","PrimaryPhone":{"FreeFormNumber":"(415) 555-9933"},"PrimaryEmailAddr":{"Address":"Cool_Cars@intuit.com"}}],"startPosition":1,"maxResults":3},"time":"2022-08-18T14:23:27.912-07:00"}"""
  4.  
  5. web::json2sba(json)
  6. web::sbadump(json)
  7. PRINT "\n\n"
  8. jsonstr = web::sba2json(json)
  9. PRINT jsonstr
  10.  

sbadump
Code: Text
  1. QueryResponse
  2.    Customer
  3.       [1]
  4.          Taxable = TRUE
  5.          BillAddr
  6.             Id = 99
  7.             Line1 = 4581 Finch St.
  8.             Line2 = crows
  9.             City = Bayshore
  10.             CountrySubDivisionCode = CA
  11.             PostalCode = 94326
  12.          ShipAddr
  13.             Id = 99
  14.             Line1 = 4581 Finch St.
  15.             Line2 = crows
  16.             City = Bayshore
  17.             CountrySubDivisionCode = CA
  18.             PostalCode = 94326
  19.          Job = FALSE
  20.          BillWithParent = FALSE
  21.          Balance = 239
  22.          BalanceWithJobs = 239
  23.          CurrencyRef
  24.             value = USD
  25.             name = United States Dollar
  26.          PreferredDeliveryMethod = Print
  27.          IsProject = FALSE
  28.          ClientEntityId = 0
  29.          domain = QBO
  30.          sparse = FALSE
  31.          Id = 1
  32.          SyncToken = 4
  33.          MetaData
  34.             CreateTime = 2022-06-07T16:48:43-07:00
  35.             LastUpdatedTime = 2022-07-15T23:48:50-07:00
  36.          GivenName = Amy
  37.          FamilyName = Lauterbach
  38.          FullyQualifiedName = Amy's Bird Sanctuary
  39.          CompanyName = Amy's Bird Sanctuary
  40.          DisplayName = Amy's Bird Sanctuary
  41.          PrintOnCheckName = Amy's Bird Sanctuary
  42.          Active = TRUE
  43.          V4IDPseudonym = 002098f70e10816c12487da5ddf91ce731f335
  44.          PrimaryPhone
  45.             FreeFormNumber = (650) 555-3311
  46.          PrimaryEmailAddr
  47.             Address = Birds@Intuit.com
  48.          DefaultTaxCodeRef
  49.             value = 2
  50.       [2]
  51.          Taxable = FALSE
  52.          BillAddr
  53.             Id = 3
  54.             Line1 = 12 Ocean Dr.
  55.             City = Half Moon Bay
  56.             CountrySubDivisionCode = CA
  57.             PostalCode = 94213
  58.             Lat = 37.4307072
  59.             Long = -122.4295234
  60.          Job = FALSE
  61.          BillWithParent = FALSE
  62.          Balance = 85
  63.          BalanceWithJobs = 85
  64.          CurrencyRef
  65.             value = USD
  66.             name = United States Dollar
  67.          PreferredDeliveryMethod = Print
  68.          IsProject = FALSE
  69.          ClientEntityId = 0
  70.          domain = QBO
  71.          sparse = FALSE
  72.          Id = 2
  73.          SyncToken = 0
  74.          MetaData
  75.             CreateTime = 2022-06-07T16:49:28-07:00
  76.             LastUpdatedTime = 2022-06-14T12:56:01-07:00
  77.          GivenName = Bill
  78.          FamilyName = Lucchini
  79.          FullyQualifiedName = Bill's Windsurf Shop
  80.          CompanyName = Bill's Windsurf Shop
  81.          DisplayName = Bill's Windsurf Shop
  82.          PrintOnCheckName = Bill's Windsurf Shop
  83.          Active = TRUE
  84.          V4IDPseudonym = 002098640048259088425d9597407a9d8707bf
  85.          PrimaryPhone
  86.             FreeFormNumber = (415) 444-6538
  87.          PrimaryEmailAddr
  88.             Address = Surf@Intuit.com
  89.       [3]
  90.          Taxable = FALSE
  91.          BillAddr
  92.             Id = 4
  93.             Line1 = 65 Ocean Dr.
  94.             City = Half Moon Bay
  95.             CountrySubDivisionCode = CA
  96.             PostalCode = 94213
  97.             Lat = 37.4300318
  98.             Long = -122.4336537
  99.          Job = FALSE
  100.          BillWithParent = FALSE
  101.          Balance = 0
  102.          BalanceWithJobs = 0
  103.          CurrencyRef
  104.             value = USD
  105.             name = United States Dollar
  106.          PreferredDeliveryMethod = Print
  107.          IsProject = FALSE
  108.          ClientEntityId = 0
  109.          domain = QBO
  110.          sparse = FALSE
  111.          Id = 3
  112.          SyncToken = 0
  113.          MetaData
  114.             CreateTime = 2022-06-07T16:51:22-07:00
  115.             LastUpdatedTime = 2022-06-15T12:59:21-07:00
  116.          GivenName = Grace
  117.          FamilyName = Pariente
  118.          FullyQualifiedName = Cool Cars
  119.          CompanyName = Cool Cars
  120.          DisplayName = Cool Cars
  121.          PrintOnCheckName = Cool Cars
  122.          Active = TRUE
  123.          V4IDPseudonym = 002098f42dce34ccf04f83aa5ffe4cc8202370
  124.          PrimaryPhone
  125.             FreeFormNumber = (415) 555-9933
  126.          PrimaryEmailAddr
  127.             Address = Cool_Cars@intuit.com
  128.    startPosition = 1
  129.    maxResults = 3
  130. time = 2022-08-18T14:23:27.912-07:00
  131.  

sba2json
Code: Script BASIC
  1. {
  2.   "QueryResponse": {
  3.     "Customer": [
  4.       {
  5.         "Taxable": true,
  6.         "BillAddr": {
  7.           "Id": "99",
  8.           "Line1": "4581 Finch St.",
  9.           "Line2": "crows",
  10.           "City": "Bayshore",
  11.           "CountrySubDivisionCode": "CA",
  12.           "PostalCode": "94326"
  13.         },
  14.         "ShipAddr": {
  15.           "Id": "99",
  16.           "Line1": "4581 Finch St.",
  17.           "Line2": "crows",
  18.           "City": "Bayshore",
  19.           "CountrySubDivisionCode": "CA",
  20.           "PostalCode": "94326"
  21.         },
  22.         "Job": false,
  23.         "BillWithParent": false,
  24.         "Balance": 239,
  25.         "BalanceWithJobs": 239,
  26.         "CurrencyRef": {
  27.           "value": "USD",
  28.           "name": "United States Dollar"
  29.         },
  30.         "PreferredDeliveryMethod": "Print",
  31.         "IsProject": false,
  32.         "ClientEntityId": "0",
  33.         "domain": "QBO",
  34.         "sparse": false,
  35.         "Id": "1",
  36.         "SyncToken": "4",
  37.         "MetaData": {
  38.           "CreateTime": "2022-06-07T16:48:43-07:00",
  39.           "LastUpdatedTime": "2022-07-15T23:48:50-07:00"
  40.         },
  41.         "GivenName": "Amy",
  42.         "FamilyName": "Lauterbach",
  43.         "FullyQualifiedName": "Amy's Bird Sanctuary",
  44.         "CompanyName": "Amy's Bird Sanctuary",
  45.         "DisplayName": "Amy's Bird Sanctuary",
  46.         "PrintOnCheckName": "Amy's Bird Sanctuary",
  47.         "Active": true,
  48.         "V4IDPseudonym": "002098f70e10816c12487da5ddf91ce731f335",
  49.         "PrimaryPhone": {
  50.           "FreeFormNumber": "(650) 555-3311"
  51.         },
  52.         "PrimaryEmailAddr": {
  53.           "Address": "Birds@Intuit.com"
  54.         },
  55.         "DefaultTaxCodeRef": {
  56.           "value": "2"
  57.         }
  58.       },
  59.       {
  60.         "Taxable": false,
  61.         "BillAddr": {
  62.           "Id": "3",
  63.           "Line1": "12 Ocean Dr.",
  64.           "City": "Half Moon Bay",
  65.           "CountrySubDivisionCode": "CA",
  66.           "PostalCode": "94213",
  67.           "Lat": "37.4307072",
  68.           "Long": "-122.4295234"
  69.         },
  70.         "Job": false,
  71.         "BillWithParent": false,
  72.         "Balance": 85,
  73.         "BalanceWithJobs": 85,
  74.         "CurrencyRef": {
  75.           "value": "USD",
  76.           "name": "United States Dollar"
  77.         },
  78.         "PreferredDeliveryMethod": "Print",
  79.         "IsProject": false,
  80.         "ClientEntityId": "0",
  81.         "domain": "QBO",
  82.         "sparse": false,
  83.         "Id": "2",
  84.         "SyncToken": "0",
  85.         "MetaData": {
  86.           "CreateTime": "2022-06-07T16:49:28-07:00",
  87.           "LastUpdatedTime": "2022-06-14T12:56:01-07:00"
  88.         },
  89.         "GivenName": "Bill",
  90.         "FamilyName": "Lucchini",
  91.         "FullyQualifiedName": "Bill's Windsurf Shop",
  92.         "CompanyName": "Bill's Windsurf Shop",
  93.         "DisplayName": "Bill's Windsurf Shop",
  94.         "PrintOnCheckName": "Bill's Windsurf Shop",
  95.         "Active": true,
  96.         "V4IDPseudonym": "002098640048259088425d9597407a9d8707bf",
  97.         "PrimaryPhone": {
  98.           "FreeFormNumber": "(415) 444-6538"
  99.         },
  100.         "PrimaryEmailAddr": {
  101.           "Address": "Surf@Intuit.com"
  102.         }
  103.       },
  104.       {
  105.         "Taxable": false,
  106.         "BillAddr": {
  107.           "Id": "4",
  108.           "Line1": "65 Ocean Dr.",
  109.           "City": "Half Moon Bay",
  110.           "CountrySubDivisionCode": "CA",
  111.           "PostalCode": "94213",
  112.           "Lat": "37.4300318",
  113.           "Long": "-122.4336537"
  114.         },
  115.         "Job": false,
  116.         "BillWithParent": false,
  117.         "Balance": 0,
  118.         "BalanceWithJobs": 0,
  119.         "CurrencyRef": {
  120.           "value": "USD",
  121.           "name": "United States Dollar"
  122.         },
  123.         "PreferredDeliveryMethod": "Print",
  124.         "IsProject": false,
  125.         "ClientEntityId": "0",
  126.         "domain": "QBO",
  127.         "sparse": false,
  128.         "Id": "3",
  129.         "SyncToken": "0",
  130.         "MetaData": {
  131.           "CreateTime": "2022-06-07T16:51:22-07:00",
  132.           "LastUpdatedTime": "2022-06-15T12:59:21-07:00"
  133.         },
  134.         "GivenName": "Grace",
  135.         "FamilyName": "Pariente",
  136.         "FullyQualifiedName": "Cool Cars",
  137.         "CompanyName": "Cool Cars",
  138.         "DisplayName": "Cool Cars",
  139.         "PrintOnCheckName": "Cool Cars",
  140.         "Active": true,
  141.         "V4IDPseudonym": "002098f42dce34ccf04f83aa5ffe4cc8202370",
  142.         "PrimaryPhone": {
  143.           "FreeFormNumber": "(415) 555-9933"
  144.         },
  145.         "PrimaryEmailAddr": {
  146.           "Address": "Cool_Cars@intuit.com"
  147.         }
  148.       }
  149.     ],
  150.     "startPosition": 1,
  151.     "maxResults":
  152.   },
  153.   "time": "2022-08-18T14:23:27.912-07:00"
  154. }
  155.  

Download Attached
« Last Edit: September 21, 2022, 12:56:09 AM by Support »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic Windows 32 bit
« Reply #2 on: September 19, 2022, 10:28:24 PM »
If you need PEEK/POKE like functionality the DLLm.dll in conjunction with the DYC extension module provides accessing STRING, INTEGER, FLOAT and DOUBLE memory locations as well as returning a VARPTR. If you have a pointer then using a string and VARPTR isn't needed. Attached is the DLLm.dll which should reside in your ScriptBasic bin directory.

Code: Script BASIC
  1. ' PEEK / POKE
  2.  
  3. declare sub dyc alias "dyc" lib "dyc"
  4.  
  5. ' STRING
  6. s="ABCDEFGH"
  7. ps=dyc("mc,p,DLLm.DLL,VARPTR,Z",s)
  8. dyc("mc,i,DLLm.DLL,POKE8,PL",ps+1,0x62)
  9. dyc("mc,i,DLLm.DLL,POKE8,PL",ps+2,0x63)
  10. PRINT LEFT(s, 8), "\n"
  11. ch=dyc("mc,i,DLLm.DLL,PEEK8,P",ps)
  12. PRINT CHR(ch),"\n"
  13. ch=dyc("mc,i,DLLm.DLL,PEEK8,P",ps+7)
  14. PRINT CHR(ch),"\n\n"
  15.  
  16.  
  17. ' INTEGERS
  18. i=""
  19. pl=dyc("mc,p,DLLm.DLL,VARPTR,Z",i)
  20. dyc("mc,i,DLLm.DLL,POKE32,PL",pl,123)
  21. iv=dyc("mc,i,DLLm.DLL,PEEK32,L",pl)
  22. PRINT iv,"\n\n"
  23.  
  24.  
  25. 'DOUBLES
  26. d=""
  27. pd=dyc("mc,p,DLLm.DLL,VARPTR,Z",d)
  28. dyc("mc,i,DLLm.DLL,POKEDOUBLE,PD",pd,1.23)
  29. dv=dyc("mc,d,DLLm.DLL,PEEKDOUBLE,P",pd)
  30. PRINT dv & "\n"
  31.  


AbcDEFGH
A
H

123

1.230000

« Last Edit: September 20, 2022, 04:53:26 PM by Support »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic Windows 32 bit
« Reply #3 on: October 01, 2022, 03:06:09 PM »
This is an update for the LCASE / UCASE bug fix done by AIR. This version is referenced as Windows32 2.3 Build 1.

bin
sbc.exe
sbw.exe
sb_engine.dll

lib
libscriba.dll