New: Console Mode editions of BBC BASIC

for discussion of bbc basic for windows/sdl, brandy and more
Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk » Mon Jul 13, 2020 8:11 pm

Yep, it works for me, tested on the RasPi build.
Matrix Brandy BASIC VI (work in progress)

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Tue Jul 14, 2020 9:47 am

Not for the first time, I'm approaching the point where I think the Console Mode editions are substantially 'complete' (but I'm quite expecting that to trigger a report that something doesn't work!).

The only things I would have liked to implement, but haven't, are the ON MOVE and ON CLOSE features of my other BASICs to allow window events to be handled. At present the different editions behave differently if you close the window: in Windows it just closes without a murmur, but in Linux and MacOS you get a warning that a process is still running and you have to choose whether to terminate it.

I don't think there's any cross-platform way of implementing these features, and I'm not familiar with the way the various OSes signal window events to console apps, so for the time being at least they will remain missing. The only event which is implemented is ON TIME (with *TIMER to set the period) so you can write programs which need to do things periodically, without polling.

The 64-bit assembler in the x86 editions is fairly comprehensive, the main shortcoming being no support for AVX. The ARM assembler in the Raspberry Pi edition is very limited however, having no support for floating point or SIMD (NEON) instructions. I'd very much like to add those but it needs somebody familiar with ARM assembly language and instruction encodings to do so, and that's not me!
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk » Tue Jul 14, 2020 12:43 pm

Richard Russell wrote:
Tue Jul 14, 2020 9:47 am
The only things I would have liked to implement, but haven't, are the ON MOVE and ON CLOSE features of my other BASICs to allow window events to be handled. At present the different editions behave differently if you close the window: in Windows it just closes without a murmur, but in Linux and MacOS you get a warning that a process is still running and you have to choose whether to terminate it.
On Linux, at least, that tends to depend on the terminal application. In xterm, it'll just close with no fanfare. Similar in lxterminal (on my carbon-dateably old Raspian installation). On the other hand, gnome-terminal gives me the running process warning.

This might be useful? https://unix.stackexchange.com/question ... was-runnin
For me it tells me when you close any of those three terminal programs, SIGHUP is sent, though in the case of gnome-terminal, after you confirm you want to close the window. However, I don't think it's possible to block the closure.
Matrix Brandy BASIC VI (work in progress)

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Tue Jul 14, 2020 2:50 pm

Soruk wrote:
Tue Jul 14, 2020 12:43 pm
However, I don't think it's possible to block the closure.
Thanks, that's helpful. If you can't block the closure it would significantly reduce the usefulness of ON CLOSE, so that's a handy reason not to worry about it! In BB4W and BBCSDL (which being GUI apps are of course rather different) ON CLOSE RETURN will simply disable the close button.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Fri Jul 17, 2020 10:56 pm

I have updated the Console Mode editions of BBC BASIC to version 0.22.

In this release I have doubled the 'escape timeout' from 100ms to 200ms, in an attempt to improve the reliability of escape detection when there is a significant latency, as may be the case if BBC BASIC and the terminal emulator are running on separate machines. I have tested this locally with the client being PuTTY running on Windows 10 and the server being a Ubuntu 18.04 machine (with an ssh connection).

To mitigate (to a degree) the doubled response time, when pressing the Escape key, I have arranged that if you press Escape twice, quickly, GET or INKEY will eventually receive two escape codes (27) rather than one. Of course this requires the default Escape action to be disabled using *ESC OFF. This doesn't mean that if you press Escape three times you will receive three keycode 27s, you won't!

Version 0.22 may be downloaded from the usual place:
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Sat Jul 18, 2020 10:38 am

Updated again to version 0.23.

I have further optimised this version so that there are now two timeouts: a shorter timeout for distinguishing between the Escape key and an 'escape sequence', and a longer timeout when waiting for the response to a cursor-position query. This should work more reliably in a client-server context because the shorter timeout applies to communication in one direction only (client to server) and the longer one to a client-server-client round-trip.

Version 0.23 may be downloaded from the usual place.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Wed Jul 22, 2020 11:40 am

I have updated the Console Mode editions of BBC BASIC to version 0.24. The changes in this version are:
  • 'Fatal' errors (e.g. 'No room' and 'Bad program'') now return to the immediate mode prompt rather than quitting.
  • Very small text programs should now LOAD correctly (previously they could be misidentified as being tokenised).
  • A minor bug in the EVAL function has been fixed (it was accidentally introduced with the LOAD command).
Version 0.24 may be downloaded from the usual place:
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk » Tue Aug 04, 2020 10:15 am

Over in the Matrix Brandy thread, where I am having a go at implementing variants, I misunderstood something you said about a variant containing a string, and indeed found I didn't get an error trying to set a variant to a string.

But, trying to read it back gave me something rather unexpected...

Code: Select all

soruk@RaspberryPi2 ~/bbcbasic $ ./bbcbasic 
BBC BASIC for Linux Console v0.24
(C) Copyright R. T. Russell, 2020
>t="Hello World"
>P.t
llo Wo
>P. t
ll t
>P.t
ttt
>P.t
 tt
>PRINT t
tRINT t
>_
Matrix Brandy BASIC VI (work in progress)

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Tue Aug 04, 2020 10:37 am

Soruk wrote:
Tue Aug 04, 2020 10:15 am
indeed found I didn't get an error trying to set a variant to a string.
Weird. Trying to assign a string to a numeric variable should give a 'Type mismatch' error (and does in BB4W and the 32-bit editions of BBCSDL). Something seems to have gone astray in the 64-bit editions resulting in this error not being reported. I'll look into it.

typemismatch.png
typemismatch.png (15.75 KiB) Viewed 775 times
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Tue Aug 04, 2020 10:44 am

Richard Russell wrote:
Tue Aug 04, 2020 10:37 am
I'll look into it.
It's just a typo. Where I should have written exprn() (evaluate a numeric expression) I wrote expr() (evaluate a numeric or string expression). It just shows that testing things that should fail is a lot harder than testing things that should work!

Thanks for the report. I'll update my sources so this is fixed in the next release.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Tue Aug 04, 2020 12:31 pm

I have updated the Console Mode editions of BBC BASIC to version 0.25. The main changes in this version are:
  • Fixed a bug which caused the expected 'Type mismatch' error not to be reported on assigning a string to a numeric variable!
  • Minor changes to the actions of the Esc key and on reporting an untrapped error, to improve consistency with other versions of BBC BASIC.
  • Added some libraries in the lib/ directory (arraylib, classlib, datelib, fnusing, sortlib, stringlib, utf8lib, xmllib).
Version 0.25 may be downloaded from the usual place:
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Wed Aug 12, 2020 11:38 am

I ought to put the source code for the Console Mode editions on git(hub) but, as usual, I don't know how to go about it. They share some of the source files of BBCSDL - those for the generic BBC BASIC interpreter and assemblers - so I don't want it to be an entirely independent project.

A Google search finds basically the same question being asked but there doesn't seem to be a universally agreed 'best' solution. Submodules appear to be one.

I fear that somebody is going to say that BBCSDL shouldn't have been one project in the first place, but instead two (the 'generic' BBC BASIC components and the SDL-specific build) but it's a bit late to change that now.

The current Console Mode makefiles are simple enough, they just pull in the relevant modules from the BBCSDL source tree:

Code: Select all

VPATH = ../../src ../../include ../../../BBCSDL/src ../../../BBCSDL/include
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
Richard Russell
Posts: 1715
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Richard Russell » Sat Sep 12, 2020 3:38 pm

I have updated the Console Mode editions of BBC BASIC to version 0.26, principally to bring them into line with the latest release of BBC BASIC for SDL 2.0. The main changes in this version are:
  • File pointers and lengths (PTR#, EXT#) are now 64-bits on all platforms.
  • Added the SYS function to return the entry point of an API, e.g. `memcpy` = SYS("memcpy").
  • Added the PTR()= statement to set the pointer of an array or structure.
  • Extended the =PTR() function to return the pointer of an array or structure.
A typical use for the PTR()= statement is to set the pointer of a linked-list node:

Code: Select all

      DIM node{link, ...}
      ...
      REPEAT
        PTR(node{}) = node.link : REM traverse linked-list
      UNTIL node.link = 0
Version 0.26 may be downloaded as follows:
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk » Wed Oct 07, 2020 9:50 pm

Richard has updated the Console Mode editions of BBC BASIC to version 0.28, to fix a couple of bugs:
  • ON ... PROC did not work correctly and could report a Syntax error even with valid code.
  • ON ERROR LOCAL could, in rare circumstances, misbehave if used in a nested function.
Version 0.28 may be downloaded as follows:
Matrix Brandy BASIC VI (work in progress)

Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk » Tue Nov 10, 2020 9:35 pm

Richard has updated the Console Mode editions to v0.29, details at the website.
Matrix Brandy BASIC VI (work in progress)

Post Reply

Return to “modern implementations of classic programming languages”