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 ... 59
1
What's New / Re: ScriptBasic Windows 32 bit
« 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

2
Source / Re: LCASE / UCASE Bug
« on: October 01, 2022, 12:26:41 PM »
AIR sent me a fix for LCASE which solved the problem. Keep an eye out in the sandbox for the fix to LCASE and UCASE in string.c.

Thanks AIR!


3
Source / LCASE / UCASE Bug
« on: October 01, 2022, 10:37:32 AM »
AIR,

As mentioned in the e-mail I sent you, Peter said that these functions need a new mortal variable and the passed variable should be only used for reference only.

Code: Script BASIC
  1. a = "Account"
  2. b = LCASE(a)
  3. PRINT a, "\n"
  4. PRINT b, "\n"
  5.  


C:\sbqbo>sbc t_lcase.sb
account
account

C:\sbqbo>


4
What's New / Re: ScriptBasic Windows 32 bit
« 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


5
What's New / Re: ScriptBasic Windows 32 bit
« 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

6
What's New / 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 ...

7
What's New / SBIDE
« on: May 28, 2021, 08:17:33 PM »
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


8
What's New / Re: ScriptBasic Core Windows 32 bit - Embedding
« on: May 25, 2021, 04: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>


9
What's New / Re: ScriptBasic Core Windows 32 bit - SQLite
« on: May 25, 2021, 03: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>


10
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>


11
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>


12
What's New / Re: ScriptBasic Core Windows 32 bit - ODBC
« on: May 25, 2021, 03: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>


13
What's New / Re: ScriptBasic Core Windows 32 bit - FFI
« on: May 25, 2021, 03: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>


14
What's New / Re: ScriptBasic Core Windows 32 bit - cURL
« on: May 25, 2021, 03: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>


15
What's New / Re: ScriptBasic Core Windows 32 bit - COM Excel
« on: May 25, 2021, 03: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.  

Pages: [1] 2 3 ... 59