Recent Posts

Pages: 1 2 3 [4] 5 6 ... 10
31
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on May 25, 2024, 01:25:56 PM »
I have restored the resources for the ScriptBasic open source project. My future contributions to this project will be limited to processing push requests by other contributors.

My efforts with SciptBasic going forward is servicing the commercial market with a supported product.

If you would like to join this forum and would be posting rather than lurking, send a request to support@scriptbasic.org for membership. It seems the current member base is either dead, retired or just too lazy to post what they're doing with BASIC if anything.


32
NOT BASIC / Fast wordlist search using a Trie
« Last post by jalih on May 18, 2024, 12:00:22 PM »
Here is a sample code for the 8th programming language demonstrating the use of a Trie for fast wordlist search. Builds a Trie from the internal 8th help sqlite database.

Code: [Select]

needs nk/gui
needs utils/help

22 font:system font:new "font1" font:atlas! drop
22 1.5 n:* constant ROW-HEIGHT
22 1.2 n:* constant LIST-ROW-HEIGHT

var numwords
var trie

a:new constant list-data

: getcount \ -- n
  list-data a:len n:1- nip ;

: getitem \ n -- s
  list-data swap a:_@ ;

: all-words \ -- a
  help_db @
  "SELECT cls||\":\"||nm FROM words ORDER BY cls,nm" db:exec[] nip
  a:squash ;

: build-trie \ -- tree numwords
  null false tree:trie all-words a:len >r ' tree:add a:each! drop r> ;

: new-win
  {
    name: "main",
    title: "8th Word Search",           
    wide: 0.5,                     
    high: 0.5,                   
    bg: "white"
  }
  nk:win
  "list" nk:list-new nk:m! ;

: list-item  \ s --
  nk:TEXT_LEFT "black" nk:label-colored ;

: search
  list-data a:clear
  trie @ "word" nk:get numwords @ tree:search nip
  a:+ drop ;

: main-render
  {
    bg: "white",
    font: "f1",
    flags: [ @nk:WINDOW_NO_SCROLLBAR ],
    word: ""
  }

  nk:begin
    null  { rows: [@ROW-HEIGHT, -1], cols: 1, rgap: 4 } nk:layout-grid-begin
      0 1 0 1 nk:grid rect>local nk:grid-push
        "word" nk:get 31 nk:EDIT_FIELD nk:PLUGIN_FILTER_DEFAULT nk:edit-string if
          "word" swap nk:set
          search
        else
          drop
        then
      1 1 0 1 nk:grid nk:rect>local nk:grid-push
        "list" nk:TEXT_LEFT LIST-ROW-HEIGHT getcount "list" nk:m@ dup>r nk:list-begin if
          LIST-ROW-HEIGHT 1 nk:layout-row-dynamic
            (
              getitem list-item
            ) r@ nk:list-range drop loop
          r@ nk:list-end
        then rdrop
    nk:layout-grid-end
  nk:end ;

: app:main
  build-trie numwords ! trie !
  new-win ' main-render -1 nk:render-loop ;
33
B4J / Re: B4J
« Last post by AlyssonR on May 18, 2024, 10:39:55 AM »
B4x is an excellent piece of software.

In addition to B4J there are also B4R (Arduino), B4I (IOS), B4A (Android) and what
caught my attention B4PPC (pocket PC). The last is only by request as the codebase
was frozen as those old PDAs fell out of use.

I haven't got much use out of it though.

34
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on May 07, 2024, 09:29:21 AM »
Most of the Windows 32 code was developed on Windows 7 so I don't see any issues running the current version of SB on it.

The OPEN statement also supports a serial port connection. I have only done a quick test long ago using AT commands to to a controller.

VB6 + VBCCR allows me to create modern UI solutions as a COM DLL. I don't use VB6 for anything else. I don't see Microsoft dropping VB6 runtime support anytime soon.

Quote
I may even take that approach and create DLLs when I get to that point.

If you go that direction let me know and I'll send you what is needed to create a form DLL.
35
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by AlyssonR on May 07, 2024, 05:13:38 AM »
Terminal interface:
All I need is an interpretation/formatting layer between serial port and terminal window
  - to take custom escape codes and put/grab data as required
  - thus reducing the static data overhead on the remote device application (with only
    a few kB of application storage)

Windows Compatibility:
I don't actually use many 'features' of Windows in my software as it is mostly file and
text-like data manipulation along with whatever maths I need to do. So long as file
handling and comms is backward compatible, the programs should run trouble free.

Small systems:
Most of my hardware projects are too small to be able to host an OS and GPIO is
handled directly on the metal. Any control from input has to be handled at that level
(i.e. assembler, C/C++ or B4R)

Historical BASIC:
I do have QB64, but I prefer SB and VBS. VBA is still a part of my version of Office.
VB6 will, it seems, never get old unless you use windows features that have been
removed. It remains (on W7) a good option for GUI and Q&D development.

I don't even use a DBMS, just a couple of random-access index files, INI tally files
and a directory tree. (mineral collection records). Storage is, after all, cheap.

For front-end - VS (VB/VC) serves well enough right now if I want a proper GUI and
SB's support on W7 breaks - right now It seems to work fine, though.

I should point out, here, that I am not interested in commercial polish since functionality
trumps all.

Socket connections:
As a friend used to say - poifick - at least where an RS232 (RS422/485) interface
don't reach directly.

36
NOT BASIC / Multithreaded Mandelbrot using 8th
« Last post by jalih on May 06, 2024, 09:44:55 PM »
Here is a multithreaded Mandelbrot program using 8 rendering threads + main GUI thread. Uses complex math for calculations.

Code: [Select]
needs nk/gui

libbin font/Roboto-Regular.ttf

font/Roboto-Regular.ttf font:new "font1" font:atlas! drop

600 constant WIDTH
600 constant HEIGHT

8 constant NUMTASKS

WIDTH HEIGHT img:new constant buffer

WIDTH 1.5 n:/ 40 n:+ constant x-axis
HEIGHT 2 n:/ constant y-axis
300 constant scale
50 constant iterations

: c:^  \ c n -- c
  >r dup c:abs r@ n:^ swap c:arg
  dup 2 a:close
  0 ( r@ n:* n:cos ) a:op!
  1 ( r> n:* n:sin ) a:op!
  swap >r ( r@ n:* ) a:map c:new rdrop ;
 
nullvar mand-task-ids

: mand-task  \ start-row end-row --
  ( drop
    (  drop
       0 0 c:new "z" t:!

       I x-axis n:- scale n:/
       J y-axis n:- scale n:/
       c:new dup "c" t:!

       c:>ri "y" t:! "x" t:!
       "y" t:@ 2 n:^ "y2" t:!
       "x" t:@ 0.25 n:- 2 n:^ "y2" t:@ n:+
       dup "x" t:@ 0.25 n:- n:+ n:* "y2" t:@ 4 n:/ n:<
       "x" t:@ n:1+ 2 n:^ "y2" t:@ n:+ 0.0625 n:< or !if
         ( "z" t:@ 2 c:^ "c" t:@ c:+ dup "z" t:!
           c:abs 2 n:> if
             765 n:* iterations n:/ dup>r 510 n:< !if
               255 255 r> 255 n:mod n:int 255 4 a:close "color" t:!
               break
             else
               r@ 255 n:< !if
                 255 r> 255 n:mod n:int 0 255 4 a:close "color" t:!
                 break
               else
                 r> 255 n:mod n:int 0 0 255 4 a:close "color" t:!
                 break
               then
             then
           else
             drop
             0 0 0 255 4 a:close "color" t:!
           then
         ) 0 iterations n:1- loop
         buffer lock J I "color" t:@ img:pix! unlock lock HEIGHT J n:- I "color" t:@ img:pix! unlock drop
       then
    ) 0 WIDTH n:1- loop
  null nk:do
  ) -rot loop ;

: start-tasks
  HEIGHT 2 n:/ NUMTASKS n:/mod 0 >r
  a:new ( r@ third n:r+ r@ n:1- 2 ' mand-task t:task-n a:push ) NUMTASKS n:1- times
  -rot n:+ r> tuck n:+ 2 ' mand-task t:task-n a:push mand-task-ids ! ;

: new-win
  {
    name: "main",
    wide: @WIDTH,
    high: @HEIGHT,
    resizable: true,
    title: "Mandelbrot"
  }
  nk:win ;

: main-render
  {
    title: "mandel",
    bg: "black",
    padding: [0,0],
    flags: [ @nk:WINDOW_NO_SCROLLBAR ]
  }

  nk:begin
    null 1 1 nk:layout-grid-begin
      0 1 0 1 nk:grid nk:rect>local nk:grid-push buffer lock nk:image buffer unlock drop
    nk:layout-grid-end
  nk:end ;

: app:main
  ' start-tasks w:is nk:rendering
  new-win ' main-render -1 nk:render-loop ;
37
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on May 06, 2024, 01:34:29 PM »
ScriptBasic has been compiled on current supported OS versions. SB isn't a substitute for QuickBasic or other ancient BASIC interpreters. I will not be supporting any Windows version earlier than Windows 10.

The Windows 32 bit version was released as a binary distribution and a compilation of my efforts over the years. I have no plans of extending this version. All development efforts going forward will be based on Windows 64 bit and Linux.

38
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on May 06, 2024, 12:00:22 PM »
The CIO extension module is used to control the console display with positioning and colors.

SB also supports a socket connection with OPEN statement.

You should checkout the RaspberryBASIC forum I host. I have examples of using the GPIO extension I created.
39
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by AlyssonR on May 06, 2024, 11:53:04 AM »
Quote
What would be really good would be a utility to take VB forms (without code) and to turn them
into viable SB forms - sadly, I know that I don't have the patience (or skill) to write it. An ANSI
terminal forms handler, OTOH, may be within my wheelhouse - sometimes a text interface is
just what the doctor ordered.

I use VB6 with VBCCR to create form / class COM DLLs as my user GUI interface on Windows 32 bit. The form events callback to SB FUNCTION / SUB routines which I use to load grids and update my DB. HERE is an example I posted in this thread. My plan was to start a new thread showing how to use VB6 + VBCCR to create a modern looking GUI that runs on Windows 10 and 11. I've held back starting this thread to see how the ScriptBasic 3.0 release and its use progressed. So far you are the only person that has taken the time to respond.

I may even take that approach and create DLLs when I get to that point.

As a fairly keen retrocomputing and MCS-51 person, ANSI terminals are very much an in technology for me and a lightweight handler for serial to display port is a definite path to reducing the (cursor addressing / graphics boxes / colour encoding) overhead on the remote board is the difference between glass teletype and VT100+ behaviours - and brings the possibility of multipage forms on board, not to mention background data logging.

The fact that a PC if considerable power is used as a terminal for a 64k text-only device is quite apart from the point - I get fed up with the disparate, pretty GUIs on remote devices that just swallow bandwidth on the network.

For reference, I use:

Windows 7
Windows Server 2008 (R2)
DOS 6.22
MCS-51 (bare metal)
Arduino ecosystem (bare metal)
40
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on May 06, 2024, 08:06:37 AM »
Quote
I was always planning on using SB in a couple of projects and I have used it in the
past for some quick and dirty admin processes across my network.

If there was a glueware class of software SB would be at the top of the list. I save a lot of money for my clients connecting processes together to automate the solution.

Quote
Variant variables and undeclared types are good - even though I prefer to declare variables.

SB by default declares variables as global to the module. This includes FUNCTION/SUB variables not passed as arguments which are local by default. You can change this with SB option settings to require that all variables be assigned or SB will not run run the script. You also set the option that all variables in FUNCTION /SUB are local by default. Normally the only time I initialize a variable is if I'm incrementing it with += or &=. SB doesn't like incrementing undef variables. I rarely use STR() or VAL() functions with SB variant variables.

PRINT "1" + "2"  would return 3
PRINT 1 & 2 would return "12" 


Quote
Arrays. I'm still used to keeping track of them by numeric indices.

I rarely use indexed based arrays. All the DB extenion modules support returning the data in associative arrays. I wrote a JSON to SB associative function (webext.sbi) that makes working with JSON a dream. HERE is an example of using the webext.sbi extension module with a JSON string.


Quote
What would be really good would be a utility to take VB forms (without code) and to turn them
into viable SB forms - sadly, I know that I don't have the patience (or skill) to write it. An ANSI
terminal forms handler, OTOH, may be within my wheelhouse - sometimes a text interface is
just what the doctor ordered.

I use VB6 with VBCCR to create form / class COM DLLs as my user GUI interface on Windows 32 bit. The form events callback to SB FUNCTION / SUB routines which I use to load grids and update my DB. HERE is an example I posted in this thread. My plan was to start a new thread showing how to use VB6 + VBCCR to create a modern looking GUI that runs on Windows 10 and 11. I've held back starting this thread to see how the ScriptBasic 3.0 release and its use progressed. So far you are the only person that has taken the time to respond.



Pages: 1 2 3 [4] 5 6 ... 10