Author Topic: The L-BASIC Interpreter  (Read 11022 times)

0 Members and 1 Guest are viewing this topic.

Offline Aurel

  • Forum Regular
  • Posts: 167
Re: The 65 BASIC Interpreter
« Reply #45 on: January 24, 2021, 12:39:39 pm »
Dav

Your coditor ...oups code editor is great and i was using it before I
modify my own to work with qb64...
so i hope that you will show us your collection
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
Re: The L-BASIC Interpreter
« Reply #46 on: January 09, 2022, 07:02:57 am »
It's been a year, but I'm finally calling it 0.1.0 - see attachment. I've updated the original post with the new supported commands, but importantly this version is capable of running STxAxTIC's sxript language!

This version can create SUBs and FUNCTIONs, with the catch that if you put the SUB/FUNCTION at the bottom of your program, you'll need a DECLARE SUB or DECLARE FUNCTION line at the top. Or, just put the SUB itself at the top of your program (that's perfectly legal in L-BASIC).

You can also have optional arguments! Example:
Code: [Select]
sub s(a, option b, option c)
    print "a = "; a;
    if option(b) then print "b = "; b;
    if option(c) then print "c = "; c;
    print
end sub

s 1
s 2, 3
s 2, 3, 4
s 2, , 4

Other working features include array resizing including _preserve, and DIM SHARED support.
* lbasic-0.1.0.bas (Filesize: 237.93 KB, Downloads: 114)

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
Re: The L-BASIC Interpreter
« Reply #47 on: January 14, 2022, 01:42:55 pm »
@luke I would love to see TI99/4A and TRS-80 BASIC interpreters :-)
The big trick for making my old TI programs work in QB64 would be replicating the sound commands. Which leads to my wishlist item for native ADSR waveform sound commands for QB64!

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
Re: The L-BASIC Interpreter
« Reply #48 on: January 16, 2022, 06:48:50 am »
Version 0.1.1 (file attached)!

I'm happy to report DECLARE SUB/FUNCTION lines are no longer needed. You can arrange your code however you want, so this is fine:
Code: [Select]
Sub s1
  s2
End Sub

s1

Sub s2
  Print "Hi"
End Sub

SELECT CASE is now implemented, including CASE IS and CASE x TO y forms.

$includes are handled, but unlike QB64 they should not go in a comment. The $ is the first character on the line, like with $checking or $screenhide in QB64.

This version is actually capable of running STxAxTIC's Sanctum 3D simulator with some very minor tweaks. Unfortunately it's rather slow - but a success nonetheless.

Full list of commands in the first post.
* lbasic-v0.1.1.bas (Filesize: 282.55 KB, Downloads: 102)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: The L-BASIC Interpreter
« Reply #49 on: January 30, 2022, 10:53:21 am »
@luke Not able to get this to work:
Code: QB64: [Select]
  1. ' test recursive sub on Luke Basic b+ 2022-01-30
  2.  
  3. recurs 1, 0, 0, 1
  4.  
  5. Sub recurs (a!, b!, c!, level%)
  6.     If level% > 10 Then
  7.         Exit Sub
  8.     Else
  9.         x! = a!
  10.         y! = b! + a!
  11.         z! = y! + c!
  12.         Print "Level:"; level%
  13.         recurs x!, y!, z!, level% + 1
  14.         Print "Level:"; level%; " x, y, z:"; x!; y!; z!
  15.     End If
  16.  
  17.  

 
lbasic error.PNG

« Last Edit: January 30, 2022, 11:28:45 am by bplus »

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
Re: The L-BASIC Interpreter
« Reply #50 on: January 30, 2022, 12:53:42 pm »
hi bplus
you can make it work by changing line 11 to call recurs (x!, y!, z!, level% + 1)
but granted it's different than QB64

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: The L-BASIC Interpreter
« Reply #51 on: January 30, 2022, 12:57:44 pm »
Thanks @jack that got it, same output as QB64.

Offline Phlashlite

  • Newbie
  • Posts: 50
Re: The L-BASIC Interpreter
« Reply #52 on: February 01, 2022, 11:00:41 pm »
This is pretty amazing!

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
Re: The L-BASIC Interpreter
« Reply #53 on: February 05, 2022, 08:42:42 am »
Well that's a rather embarrassing mistake to have made! A small typo meant it thought Subs were Functions for the purposes of setting a return value. Here's a fixed version 0.1.2, which also includes a bunch of new commands (notably mouse support) and preliminary support for returning arrays from functions.
* lbasic-v0.1.2.bas (Filesize: 307.71 KB, Downloads: 109)