Coding SuperBasic

Helpful tips and guides, also new users can ask for help here.
dlsa
ROM Dongle
Posts: 10
Joined: Thu Nov 03, 2022 7:26 pm

Coding SuperBasic

Post by dlsa »

Hello all,

The QL's operating system includes the SuperBasic interpreter. But is it possible to write a program to one or more text files and then use a compiler to build an executable ?

Thanks,
Regards


User avatar
dex
Gold Card
Posts: 286
Joined: Thu Dec 23, 2010 1:40 pm

Re: Coding SuperBasic

Post by dex »

Never heard about QLiberator or Turbo?


User avatar
NormanDunbar
Forum Moderator
Posts: 2281
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Coding SuperBasic

Post by NormanDunbar »

You can, as already mentioned above, write your code in the interpreter and compile it, after testing, with QLiberator or Turbo. That's probably the standard method.

However, you can use SSB (Structured SuperBasic) which allows you to write your code in an editor, without line numbers, then generate an actual SuperBASIC file with line numbers ready to test and then compile.

SSB is a fantatic utility.

I run Linux and I have QPC2 as my QL emulator. I code in VSCode in Linux, then execure SSB in the emulator. That reads the _ssb source and generates a _bas file in the same (Linux) location. That can then be loaded into the interpreter and tested.

If ypu read the thread on SSB (link below) there is a link to a version I created to fix a buglet and to make a couple of changes to generste code thd wsy I like it. Controlled by environment variables of course!

HTH



There's a good thread on SSB, where to get it etc at viewtopic.php?t=4207.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
dlsa
ROM Dongle
Posts: 10
Joined: Thu Nov 03, 2022 7:26 pm

Re: Coding SuperBasic

Post by dlsa »

My main problem is the line numbers. I usually program away at the interpreter in these old computers (also in the ZX Spectrum).
Because I don't do any planning of the program before, the line numbering sometimes get in the way.

I have heard of Turbo, but never of SSB. I will give it a try.

Thanks for all the help


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Coding SuperBasic

Post by dilwyn »

I've used SSB during the coding of the QLirc program for using IRC on QL emulators which have access to the TCP/IP of the host computer. It took me a while to adapt to its way of working. SSB is a great utility, but you'll need to choose your editor carefully to get the best from it. Most QL editors are designed for editing plain text files OK, but not all are up to the task of editing QL BASIC programs - considerations such as line length, word wrapping behaviour and ability to copy and paste adequately , for example.

I expect you'll get different answers from everyone as to which QL-based editor might be the best choice, so I won't try to suggest one - there's a selection on my page at http://www.dilwyn.me.uk/editview/index.html

It is on my "to do" list to write a fairly simple editor more geared up to handling BASIC programs than text, but that's for the future. I have a much bigger "to do" list of QL software to write than I'll ever get time to write I guess :oops: :ugeek:

You can of course use a non-QL editor to prepare the QL BASIC programs as plain text files - just remember that the QL requires a linefeed CHR$(10) only as end of line character, not a carriage return, and you may need to translate the odd character to QL character set equivalents upon transfer from an editor on, say, a Windows system.

Good luck, and welcome to the Forum.


User avatar
NormanDunbar
Forum Moderator
Posts: 2281
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Coding SuperBasic

Post by NormanDunbar »

dlsa wrote: Tue Nov 22, 2022 12:28 pm I have heard of Turbo, but never of SSB. I will give it a try.
SSB is not a compiler as such, well, technically it's a "transpiler" it takes in source code without line numbers etc, and spits out a file containing the line numbers. It is, however, a great help in writing SuperBASIC code when you don't like using line numbers and occasionally (or frequently) want to move things around.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
NormanDunbar
Forum Moderator
Posts: 2281
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Coding SuperBasic

Post by NormanDunbar »

dilwyn wrote: Tue Nov 22, 2022 1:06 pm You can of course use a non-QL editor to prepare the QL BASIC programs as plain text files - just remember that the QL requires a linefeed CHR$(10) only as end of line character, not a carriage return, and you may need to translate the odd character to QL character set equivalents upon transfer from an editor on, say, a Windows system.
When I was working, back in the day, I had to write scripts and code for Uinx boxes on a Windows PC. I used Notepad++ (https://notepad-plus-plus.org/) as my editor of choice. Line endings were set to Unix by default, and if I needed an actual Windows file, it can be simply changed while editing the file.

Thoroughly recommended.

dilwyn wrote: Tue Nov 22, 2022 1:06 pm It is on my "to do" list to write a fairly simple editor more geared up to handling BASIC programs than text
Sounds very interesting Dilwyn, although I#m slightly puzzled in that SuperBASIC files are plain text. Do you have a (brief) list of features that you might be planning to implement?


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
Andrew
Aurora
Posts: 796
Joined: Tue Jul 17, 2018 9:10 pm

Re: Coding SuperBasic

Post by Andrew »

NormanDunbar wrote: Tue Nov 22, 2022 2:14 pm I used Notepad++ (https://notepad-plus-plus.org/) as my editor of choice. Line endings were set to Unix by default, and if I needed an actual Windows file, it can be simply changed while editing the file.

Thoroughly recommended.
Me too. And I added Superbasic syntax highligting.
To install SuperBasic syntax highlight: from menu select Language -> User Defined language -> Define your language -> Import
and import the attached file
Attachments
QL SuperBasic.zip
(2.37 KiB) Downloaded 103 times


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Coding SuperBasic

Post by mk79 »

dlsa wrote: Mon Nov 21, 2022 8:50 pmThe QL's operating system includes the SuperBasic interpreter. But is it possible to write a program to one or more text files and then use a compiler to build an executable ?
I think that's what the Basic Linker was for https://www.wlenerz.com/qlstuff/#basic_linker


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Coding SuperBasic

Post by dilwyn »

NormanDunbar wrote: Tue Nov 22, 2022 2:14 pm
dilwyn wrote: Tue Nov 22, 2022 1:06 pm It is on my "to do" list to write a fairly simple editor more geared up to handling BASIC programs than text
Sounds very interesting Dilwyn, although I#m slightly puzzled in that SuperBASIC files are plain text. Do you have a (brief) list of features that you might be planning to implement?
Cheers,
Norm.
Before you get over-excited, Norman, nothing too ambitious. No syntax checking or highlighting, for example (I'm not clever enough).

Using code which already partly exists in my ProcMan software (which handles untokenised BASIC files), it'd have :

Proc/Fn listing (enabling you to cut/copy/paste/jump to individual procs/fns or view lists of procs/fns
Copy and Paste for areas of code
Merge in or extract library routines
Elementary QREF-style operations - see lists of identifiable routine and variable names
Add/remove line numbers
Labels for no-line-number listings for when you choose to add line numbers (only needed if you are desperate enough to need to use GOTO/GOSUB).

So, nothing too ambitious or drastic, but having some QL BASIC awareness.

No code has been written, just a document outlining what I want to aim for with it. If it happens at all, it won't be before next year. I foolishly let people know I'd retired early, and got dragged into all sorts of committees and activities and things, and now seem to have less free time than when I was working! :roll:


Post Reply