Author Topic: ScriptBasic 3.0  (Read 548 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
ScriptBasic 3.0
« on: March 15, 2024, 11:52:51 PM »
AIR has created a MSVC version of ScriptBasic for Windows 64 bit which also compiles on Linux. Both platforms use the ScriptBasic build system which generates new .h and help files from the source.

I'm in the process of testing the new 3.0 build and will create an Inno installer for the release.

ScriptBasic runs in the following modes.
  • Embeddable scripting API as a DLL/so. (libscriba)
  • Console mode interpreter. (sbc)
  • Windows GUI interpreter with Windows style support. (sbw) This version doesn't pop a console or supports redirection.
  • Proxy / standalone application web server. (sbhttpd) The server runs as a service on Windows.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #1 on: March 16, 2024, 12:14:13 AM »
The SBW version of ScriptBasic will be a separate project repo maintained by me. It will be compiled in GCC and include the IUP extension module DLL. SBW is able to use all the extension modules in AIR's MSVC project.

SBW and IUP will also run on Linux.


Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #2 on: March 16, 2024, 12:32:13 AM »
I will be maintaining the 32 bit version of ScriptBasic for Windows. This version will continued to be compiled in GCC except for the COM extension module and VB6 support code which is compiled in Visual Studio.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #3 on: March 17, 2024, 01:40:17 AM »
If you like ScriptBasic's direction and would like to contribute to the project with extension modules and example code, post your code to the forum for review for inclusion.

If you're not a member of the forum, you can e-mail your code to me (support@allbasic.info) and I will post it on your behalf.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #4 on: March 19, 2024, 11:44:55 PM »
The Gitlab ScriptBasic repository supports a markdown wiki. The ScriptBasic build system generates its html documentation from the C source. My plan is to tweak the build system to generate a like markdown alternative.

The Gitlab wiki is treated like a repository which git can work with. Updating the wiki after a new build that may have documentation added is as simple as a git push.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #5 on: March 23, 2024, 12:14:02 AM »
I have finished testing AIR's MSVC build and it's ready for use. You will need the following tools to build the executables and documentation

MSVC from Microsoft Visual Studio  (Free version works fine)

Strawberry Perl for Windows the ScriptBasic build system uses.

Included in the repo is VC-3rdParty-Libs.7z which contains module runtime DLLs and lib / include files for MSVC.

This devcmd.bat file sets up the environment to build the ScriptBasic Windows 64 bit distribution. This batch file is for AIR's custom portable MSVC version. (all inclusive) You will need to setup your paths accordingly. The devcmd.bat file is run within this custom MSVC directory.
Code: DOS
  1. @echo off
  2.  
  3. set WindowsSDKDir=%~dp0\Windows Kits\10
  4. set WindowsSDKVersion=10.0.22621.0
  5. set VCToolsInstallDir=%~dp0\VC\Tools\MSVC\14.39.33519\
  6. set VSCMD_ARG_TGT_ARCH=x64
  7.  
  8. set MSVC_BIN=%~dp0\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64
  9. set SDK_BIN=%~dp0\Windows Kits\10\bin\10.0.22621.0\x64;%~dp0\Windows Kits\10\bin\10.0.22621.0\x64\ucrt
  10. set PATH=%MSVC_BIN%;%SDK_BIN%;%PATH%
  11. set INCLUDE=%~dp0\VC\Tools\MSVC\14.39.33519\include;%~dp0\Windows Kits\10\Include\10.0.22621.0\ucrt;%~dp0\Windows Kits\10\Include\10.0.22621.0\shared;%~dp0\Windows Kits\10\Include\10.0.22621.0\um;%~dp0\Windows Kits\10\Include\10.0.22621.0\winrt;%~dp0\Windows Kits\10\Include\10.0.22621.0\cppwinrt
  12. set INCLUDE=%INCLUDE%;%~dp0\VC-3rdParty\include
  13. set LIB=%~dp0\VC\Tools\MSVC\14.39.33519\lib\x64;%~dp0\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64;%~dp0\Windows Kits\10\Lib\10.0.22621.0\um\x64;%~dp0\VC-3rdParty\lib\x64
  14.  
  15. call %~dp0\Perl\portableshell.bat
  16.  

Here is an example to show how %~dp0 works.
Code: DOS
  1. Here is D:\dirshow.bat:
  2.  
  3. @echo off
  4. echo this is %%~dp0 %~dp0
  5.  
  6. Run it from C:\ and this is what you see
  7.  
  8. C:\>D:\dirshow.bat
  9.  
  10. this is %~dp0 D:\
  11.  


I have attached the directory tree structure for AIR's MSVC.

After you run the devcmd.bat file, change directory to where your your ScriptBasic source is located. This source directory must be from a git clone https://gitlab.com/scriptbasic/sb-dev-msvc.git command. The ZIP and other download methods don't seem to get everything. Once in the source directory run this command. setup If you add --help to the command it will show the option commands.

Once the build process is complete, you can use the setup --install --directory=C:\ScriptBasic64 command to create a runtime directory. Copy the DLL directory contents from VC-3rdParty-Libs.7z to your runtime lib directory. The last step is to add the bin and lib directory to your system PATH.

ScriptBasic MSVC Repository
« Last Edit: March 23, 2024, 02:20:29 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #6 on: March 24, 2024, 02:31:20 AM »
I have made AIR's MSVC portable C compiler with Perl included available as a download. This versions has all the updates that are include in the VC-3rdParty-Libs.7z for MSVC. It's a 342 MB zip file.

https://scriptbasic.org/files/MSVC-AIR.zip

Just clone the repo and download AIR's MSVC and you're set to compile a 64 bit ScriptBasic for Windows.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #7 on: March 24, 2024, 03:16:32 AM »
After running setup in your ScriptBasic cloned source directory, run setup --install --directory=C:\ScriptBasic64 for your runtime version. I've attached my examples directory so you can try out the extension modules below.

  • cio_colors.sb - Display all 256 colors and their value. This module allows you to control the console screen.
  • curl_wget.sb - Using the cURL extension module to download a file.
  • gmpmath.sb - GMP large integer math module. (+ - * /)
  • sbt_main.sb - Example of ScriptBasic running in threaded mode.
  • sql_odbc.sb - ODBC connected to a MS SQL Server displaying a couple columns in a table.
  • sqlite_demo.sb - Example of a create insert and select with a SQLite table.
  • testmysql.sb - Connecting to the MySQL example DB and get the data from the products table.
  • testmxml.sb - Example of using the Mini XML module.

Offline AlyssonR

  • Advocate
  • Posts: 126
Re: ScriptBasic 3.0
« Reply #8 on: March 24, 2024, 01:30:16 PM »
Wonderful stuff.

I will take a look when I next take a break from hardware development.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #9 on: March 24, 2024, 02:28:09 PM »
I have added the sbw gcc compiled interpreter to the repo as a zip. This version of ScriptBasic is compiled with no console and has Windows style / theme support for current common controls.

I plan to create a repo for Windows 64 / 32 bit builds using gcc which uses static .h files and creates no documentation from source. All that's needed to compile this version of ScriptBasic is the TDM-GCC-64/32. compiler (open source & free)

If you only need to extend ScriptBasic with C library extension modules the gcc version is a lightweight compile option. This version doesn't compile on Linux and is for Windows 32/64 bit only.

If you plan on modifying ScriptBasic core source, the MSVC version is the way to go.  It builds new .h files and documentation from source. The build system does all the heavy lifting for you.

Offline jack

  • Contributor
  • Posts: 15
Re: ScriptBasic 3.0
« Reply #10 on: March 24, 2024, 07:10:25 PM »
Hi John  :)
I am interested in using libscriba.dll, are there any examples?
with the help of fbfrog I translated scriba.h to scriba.bi, so I am ready to try using libscriba with FreeBasic but I need a skeleton example
an example in C would be good, I should be able to translate it to FB

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #11 on: March 24, 2024, 07:32:42 PM »
Jack,

Here is an example of calling the libscriba.dll using the SBT extension module.

Code: ScriptBasic
  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.  

Output

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

Looking at the SBT extension module C source may be helpful as well.


Before Charles moved his hosting preference to Theo's forum I was testing embedding libscriba.dll with OxygenBasic.

O2 SB Embed
« Last Edit: March 24, 2024, 08:23:20 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #12 on: March 25, 2024, 03:00:46 AM »
setup can fully customize how your runtime file structure is laid out and configuration file defined. Take a peek at the setup.pl file for how setup options work.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: ScriptBasic 3.0
« Reply #13 on: March 25, 2024, 03:28:05 AM »
Charles Pegg created a ScriptBasic extension module called DLLC with OxygenBasic which was a scriptable FFI, virtual DLLs and ability to compile virtual assembly code. I'm going to try and get it working with 64 bit. Any O2 pros / Charles willing to help get this module working, let me know.

P.S.

I'm no longer interested in IUP support any longer in DLLC.

Offline jack

  • Contributor
  • Posts: 15
Re: ScriptBasic 3.0
« Reply #14 on: March 25, 2024, 04:02:07 AM »
thank you John