BBC BASIC for SDL 2.0 version 1.05a released

for discussion of bbc basic for windows/sdl, brandy and more
Post Reply
User avatar
Richard Russell
Posts: 1556
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

BBC BASIC for SDL 2.0 version 1.05a released

Post by Richard Russell » Thu Jul 25, 2019 3:49 pm

I have released version 1.05a of BBC BASIC for SDL 2.0, the cross-platform programming language for Windows, MacOS, Linux, Raspbian (Raspberry Pi), Android and iOS. The changes in this version are as follows:
  1. BASIC Interpreter / Run Time Engine

    Fixed a bug causing MOUSE and graphics coordinates to diverge if the window is resized without doing a VDU 26.

    Incorporated Jonathan Harston's modification to ignore SOUND statements specifying non-internal sound channels.

  2. IDEs and Utilities

    The SDLIDE list of functions and procedures can now be scrolled using the PgUp and PgDn keys.

    SDLIDE will now load programs in plain text (.bas) format even if they contain TAB characters.

    Added a Go To Line menu selection to SDLIDE, similar to that in BBC BASIC for Windows v6.12a.

    Modified the search utility to fix a problem with it not having keyboard focus initially.

  3. Libraries

    dlglib.bbc now supports comboboxes!

    Fixed a bug in datelib.bbc causing the FN_date$() function to misbehave with months starting with an M (March and May). D'oh!

    The DejaVuSans font has been updated to a newer version with more Unicode symbols.

    Added the (incomplete) bigint.bbc library in case somebody fancies developing it further.

  4. Example Programs

    Added a graphics demo fluid.bbc which uses GPU shader code to create a plasma-like effect.

    Modified dlgdemo.bbc to demonstrate the new combobox capability of the dialogue box library.

    Modified hangman.bbc to remove code which worked around the now fixed coordinate disparity.

    Added a 3D animation to accompany skaters.bbc. This has a rather risqué Easter Egg, can you find it?!
This new version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspbian, iOS and 64-bit Linux editions, currently).

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

Re: BBC BASIC for SDL 2.0 version 1.05a released

Post by Richard Russell » Sat Aug 24, 2019 6:17 pm

Somebody has posted this, unbidden, at the BBC BASIC forum (and, no, it's not me posting under an alias):

"I just want to let people know that I finally did the effort to use structures in my programs and that this was a revelation. Big words but justified. I know Richard has made the effort to implement structures already some years ago. And, at the time, I made a minor effort to work with them only to put them aside quite quickly. Not that they were not useful or to difficult to use. I simply looked for the old familiar ways to solve my programming issues. Lazy !

I couldn't have been more wrong. This week I did the effort to carefully read the manual and started to code a new program including several arrays of structures, mixing different data types within the structures. The code I've produced after some tinkering is now finalized. It is compact, symmetric, much more readable,... and so much easier/faster to code. For those who already use this I am of course stating the obvious. For those who don't : read the manual , then give structures a try. This language is so rich !
"

Naturally I entirely agree with this, and I am in no doubt that structures are one of the most valuable extensions that I have made to the language. But nevertheless structures in BBC BASIC remain controversial. Some people say that they can't see the point, given that everything you can do with structures you can do with indirection (whilst that is arguably true, it's what you can do elegantly, easily, safely and quickly that matters more).

Structures have particular value in the context of moving from 32-bits to 64-bits. If you are using indirection you are necessarily working with addresses (typically of memory allocated with DIM); if those addresses may be 64-bit values then you have to assign them to 64-bit variables which means that programs need modifying. But the structure syntax is blind to the size of addresses and programs using them will run on a 64-bit system without modification.

I'd like to see structures implemented in other versions of BBC BASIC (e.g. Matrix Brandy) and I'd like to see them implemented in a way compatible with BBC BASIC for Windows and BBC BASIC for SDL 2.0. But I know that's a tall order when there is such a range of opinions (I expect there would be pressure from some quarters to be compatible with Basalt's structures instead).

julie_m
Posts: 212
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BBC BASIC for SDL 2.0 version 1.05a released

Post by julie_m » Sun Aug 25, 2019 2:14 pm

Structures definitely make sense. They are a good compromise between the simple scalar and array variables used by simple BASIC implementations, and full-on user-defined object types used by the likes of Java and JavaScript.

If I could take just one of the lessons learned in my programming career, such as it is, it would have to be:
Design your data structures correctly, and your program will more or less write itself from then on.
You can replace a whole bunch of separate arrays e.g.

Code: Select all

name$(I%), height(I%), weight(I%)
and so forth, where I% is the common index into each of them, with just one array indexed on I% and each element having all those properties in it.

This is what the User Guide is getting at in an innocent sentence about building up quite complex expressions with the ?, ! and $ memory operators. You can write PROCs to set properties within a structure, and FNs to get them -- exactly as I did the test code for my project, BCP. Now functionality like data structures is just baked right into the language itself -- how cool is that?

BCP is written mainly in 6502 assembly language, since it's intended to run on real, ancient kit; but if I was writing a version to run on modern, fast hardware, then it would definitely make sense to use structures to represent the various objects it used. The data structures are so central to it, I ended up writing code to emulate that functionality!

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

Re: BBC BASIC for SDL 2.0 version 1.05a released

Post by Richard Russell » Tue Aug 27, 2019 3:45 pm

julie_m wrote:
Sun Aug 25, 2019 2:14 pm
You can replace a whole bunch of separate arrays e.g.

Code: Select all

name$(I%), height(I%), weight(I%)
and so forth, where I% is the common index into each of them, with just one array indexed on I% and each element having all those properties in it.
Absolutely. In the syntax I devised for BBC BASIC for Windows and BBC BASIC for SDL 2.0 you'd create the structure array thus:

Code: Select all

      DIM objects{(num%) name$, height, weight}
or alternatively you can do it in two steps:

Code: Select all

      DIM object{name$, height, weight}
      DIM objects{(num%)} = object{}
Once created you can do useful things like pass the entire array of structures to a PROC or FN, or pass just one element of that array, or just one member:

Code: Select all

      PROChandle_entire_array(objects{()})
      PROChandle_one_element(objects{(I%)})
      PROChandle_one_member(objects{(I%)}.height)
The things you can usually do with an array, like find the number of elements, work too:

Code: Select all

      size_of_array = DIM(objects{()},1)
although there's no meaningful equivalent to SUM() or SUMLEN() with an array of structures!

Post Reply

Return to “modern implementations of classic programming languages”