BASIC Developer & Support Resources > Scripting Languages

ScriptBasic Windows 32

(1/4) > >>

John:
I'm in the process of building a new ScriptBasic Windows 32 release using TDM-GCC-32 9.20 and an enhanced makefile AIR initially created. I have eliminated scriba.exe and created sbc.exe (console) and sbw.exe (Windows) which both support Windows styles if running IUP forms or VB6 OCX forms.

I'm working on porting GMP3, MXML and the new JSON extension modules to Windows. DLLC will also be included. I will be using the Inno installer for the release. I will be setting up a new project in the sandbox for sbwin-dev.

I hope to include a set of examples showing how to use each of the extension modules.

I had the opportunity to work with Postgres SQL with a project I'm working on with a client. I really like the DB Server and would like to update the existing PSQL extension module to work with the current release. I'm not planning on including it in this next release but will offer it as an addon when updated and tested.

John:
GMP
┬źArithmetic without limitations┬╗


I was able to get the gmp3 (large number library) working on Windows 10.

GMP3 Include

--- Code: Script BASIC ---module gmp3 declare sub     ::init     alias "init"     lib "gmp3"declare sub     ::init_set alias "init_set" lib "gmp3"declare sub     ::mul      alias "mul"      lib "gmp3"declare sub     ::mul_si   alias "mul_si"   lib "gmp3"declare sub     ::add      alias "add"      lib "gmp3"declare sub     ::sub      alias "sub"      lib "gmp3"declare sub     ::divide   alias "divide"   lib "gmp3" end module 


--- Code: Script BASIC ---DECLARE SUB BI_ADD  ALIAS  "add"     LIB "gmp3"DECLARE SUB BI_SUB  ALIAS  "sub"     LIB "gmp3"DECLARE SUB BI_MUL  ALIAS  "mul"     LIB "gmp3"DECLARE SUB BI_DIV  ALIAS  "divide"  LIB "gmp3" a = "10000000000"b = "9999999999" PRINT "ADD: ", BI_ADD(a,b),"\n"PRINT "SUB: ", BI_SUB(a,b),"\n"PRINT "MUL: ", BI_MUL(a,b),"\n"PRINT "DIV: ", BI_DIV(a,2),"\n" 

C:\ScriptBASIC\examples>sbc gmp3test.sb
ADD: 19999999999
SUB: 1
MUL: 99999999990000000000
DIV: 5000000000

C:\ScriptBASIC\examples>


ScriptBasic supports large strings as well native.


--- Code: Script BASIC ---a = STRING(1234567890,CHR(0))           PRINT LEN(a),"\n" 

C:\ScriptBASIC\examples>sbc bigstr.sb
1234567890

C:\ScriptBASIC\examples>

John:
I was able to get the json extension module AIR created for Linux working on Windows 10.

JSON Include

--- Code: Script BASIC ---module json ' FUNCTION DECLARATIONS declare sub     ::loadfile alias "loadfile" lib "json"declare sub     ::loadstr  alias "loadstr"  lib "json"declare sub     ::save     alias "save"     lib "json"declare sub     ::count    alias "count"    lib "json"declare sub     ::object   alias "object"   lib "json"declare sub     ::get      alias "get"      lib "json"declare sub     ::new      alias "new"      lib "json"declare sub     ::settext  alias "settext"  lib "json"declare sub     ::setnum   alias "setnum"   lib "json" end module 


--- Code: Script BASIC ---' SB JSON Create Entries import json.sbi root = json::New()json::SetText(root,"client1.name","Joe Blow")json::SetNum(root,"client1.age", 56)json::SetText(root,"client1.address.city","Tarrytown")json::SetText(root,"client1.address.state","NY")json::SetText(root,"client1.address.zip","10891") json::SetText(root,"client2.name","John Smith")json::SetNum(root,"client2.age",86)json::SetText(root,"client2.address.city","Cupertino")json::SetText(root,"client2.address.state","CA")json::SetText(root,"client2.address.zip","N/A")json::Save("root.json") 
Output

--- Code: Text ---{    "client1": {        "name": "Joe Blow",        "age": 56,        "address": {            "city": "Tarrytown",            "state": "NY",            "zip": "10891"        }    },    "client2": {        "name": "John Smith",        "age": 86,        "address": {            "city": "Cupertino",            "state": "CA",            "zip": "N\/A"        }    }} 
Parse the above generated root.json file.


--- Code: Script BASIC ---' SB READ IN CREATED JSON import json.sbi jObject = json::loadfile("root.json")for i = 0 to json::count(jObject)-1    obj = json::object(jObject,i)    print string(40,"-"),"\n"    print json::Get(obj,"name"),"\n"    print json::Get(obj,"age"),"\n"    print json::Get(obj,"address.city"),"\n"    print json::Get(obj,"address.state"),"\n"    print json::Get(obj,"address.zip"),"\n"nextprint string(40,"-"),"\n" 
Output

C:\ScriptBASIC\examples>sbc parse.sb
----------------------------------------
Joe Blow
56
Tarrytown
NY
10891
----------------------------------------
John Smith
86
Cupertino
CA
N/A
----------------------------------------

C:\ScriptBASIC\examples>

John:


This is the Mini XML (mxml) library static linked to the extension  module. AIR's latest version.

MXML Include

--- Code: Script BASIC ---module mxml declare sub     ::LoadDoc       alias "LoadDoc"       lib "mxml"declare sub     ::GetNext       alias "GetNext"       lib "mxml"declare sub     ::GetChild      alias "GetChild"      lib "mxml"declare sub     ::GetNodeValue  alias "GetNodeValue"  lib "mxml"declare sub     ::GetNode       alias "GetNode"       lib "mxml"declare sub     ::SaveDoc       alias "SaveDoc"       lib "mxml"declare sub     ::NewDoc        alias "NewDoc"        lib "mxml"declare sub     ::GetProperty   alias "GetProperty"   lib "mxml"declare sub     ::FreeDoc       alias "FreeDoc"       lib "mxml" end module 


--- Code: Script BASIC ---include mxml.sbi filename = "mxml_demo.xml" doc = mxml::LoadDoc(filename) node =  mxml::GetNode(doc,"/stufflist/stuff_test")if node then print "Test1: ", mxml::GetNodeValue(node),"\n" node =  mxml::GetNode(doc,"/stufflist/stuff_test2")if (node) then print "Test2: ", mxml::GetNodeValue(node),"\n\n"  node = mxml::GetNode(doc,"/stufflist/stuff_test3/painting/img")if node then        print "Image: ", mxml::GetProperty(node,"src"), "\n"        print "Alt Image: ", mxml::GetProperty(node,"alt"), "\n\n"endif  node = mxml::GetNode(doc,"/stufflist/books")child = mxml::GetChild(node) while child        node = mxml::GetNode(child,"id")        if node then print "ID = ", mxml::GetNodeValue(node),"\n"        node = mxml::GetNode(child,"name")        if node then print "Name = ", mxml::GetNodeValue(node),"\n"         child = mxml::GetNext(child)wend  if doc then mxml::FreeDoc(doc) 
mxml_demo.xml

--- Code: XML ---<?xml version="1.0" encoding="UTF-8" ?>  <stufflist>        <stuff_test>This is a test!</stuff_test>        <stuff_test2>And this is another test!</stuff_test2>        <stuff_test3>                <painting>                        <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>                        <caption>This is Raphael's "Foligno" Madonna, painted in                                 <date>1511</date>.                        </caption>                </painting>        </stuff_test3>        <books>    <book>        <id>1</id>        <name>Hello, world!</name>    </book>    <book>        <id>2</id>        <name>Hello, China!</name>    </book>        </books></stufflist> 
Output

C:\ScriptBASIC\examples>sbc mxml_demo.sb
Test1: This is a test!
Test2: And this is another test!

Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael

ID = 1
Name = Hello, world!
ID = 2
Name = Hello, China!

C:\ScriptBASIC\examples>

John:
DLLC is an extension module created by Charles Pegge in Oxygen Basic which he is the author of. Oxygen Basic is a JIT BASIC (like) compiler that generates ASM source. O2 is written in itself.

The DLLC extension module provides the following features.

[*] Dynamic FF! definition and calling of DLL libraries.
[*] Access and define C structures.
[*] Access, create and translate OLE strings (BSTR) and wide strings (unicode)
[*] Dynamically create virtual (DLL) functions from ScriptBasic with O2 JIT compiler.
[*] Low level COM / GUID  functions.
[/list]

I plan to demonstrate a few of DLLC's features in upcoming posts to this thread.

dllc.sbi

--- Code: Script BASIC ---'  supported types:'  b bool'  c char'  d double precision float'  f float'  h handle'  i integer (32bit)'  p pointer'  q quad (64bit) integer'  s short (16bit) integer'  z null terminated string '  supported calling conventions'  cdecl'  stdcall '  '*' signifies pass variable by reference, otherwise by value    'DIAGNOSTICS    declare sub dllhook alias "dllhook" lib "DLLC"  declare sub dllshow alias "dllshow" lib "DLLC"  declare sub dllreco alias "dllreco" lib "DLLC"  declare sub dllsecs alias "dllsecs" lib "DLLC"  declare sub dllerrc alias "dllerrc" lib "DLLC"  declare sub dllerrs alias "dllerrs" lib "DLLC"   'CONSOLE  declare sub dllcnsl alias "dllcnsl" lib "DLLC"  declare sub dlllnpt alias "dlllnpt" lib "DLLC"  declare sub dllprnt alias "dllprnt" lib "DLLC"  declare sub dllcmnd alias "dllcmnd" lib "DLLC"  'DLL LINKAGE  declare sub dllfile alias "dllfile" lib "DLLC"  declare sub dllproc alias "dllproc" lib "DLLC"  'DLL CALLS  declare sub dllmeth alias "dllmeth" lib "DLLC"  declare sub dllcall alias "dllcall" lib "DLLC"  declare sub dllcald alias "dllcald" lib "DLLC"  declare sub dllcalt alias "dllcalt" lib "DLLC"  declare sub dllcobj alias "dllcobj" lib "DLLC"  declare sub dllcobt alias "dllcobt" lib "DLLC"  declare sub dllclbk alias "dllclbk" lib "DLLC"  'SBCALLS  declare sub dllprog alias "dllprog" lib "dllc"  declare sub dllendp alias "dllendp" lib "dllc"  declare sub dlltran alias "dlltran" lib "DLLC"  'CHANNELS AND THREADS  declare sub dllidat alias "dllidat" lib "DLLC"  declare sub dllodat alias "dllodat" lib "DLLC"  declare sub dllclos alias "dllclos" lib "DLLC"  declare sub dllwait alias "dllwait" lib "DLLC"  'DATA  declare sub dllsptr alias "dllsptr" lib "DLLC"  declare sub dlltype alias "dlltype" lib "DLLC"  declare sub dlldimv alias "dlldimv" lib "DLLC"  declare sub dllfill alias "dllfill" lib "DLLC"  declare sub dllgetm alias "dllgetm" lib "DLLC"  declare sub dllputm alias "dllputm" lib "DLLC"  declare sub dllptrm alias "dllptrm" lib "DLLC"  declare sub dllfrem alias "dllfrem" lib "DLLC"  'STRINGS / GUIDS  declare sub dlldelo alias "dlldelo" lib "DLLC"  declare sub dllostr alias "dllostr" lib "DLLC"  declare sub dllzstr alias "dllzstr" lib "DLLC"  declare sub dllastr alias "dllastr" lib "DLLC"  declare sub dllwstr alias "dllwstr" lib "DLLC"  declare sub dllcast alias "dllcast" lib "DLLC"  declare sub dllguid alias "dllguid" lib "DLLC" '  current limits:'  =============== '  32   parameters per procedure'  2048 entities (total of libs+procs+types+vars) 

Navigation

[0] Message Index

[#] Next page

Go to full version