Structured SuperBASIC

Anything QL Software or Programming Related.
User avatar
pjw
QL Wafer Drive
Posts: 1607
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Structured SuperBASIC

Post by pjw »

NormanDunbar wrote: Wed Aug 28, 2024 4:26 pm <>
Per, thanks. I was aware that a compiled program might have troubles accessing the real Basic area, but I am trying out a couple of workarounds. One of which is as how you did it in the boot file for Qliberator 346u, getting A6 from the JCB list. But, I'm not convinced that will work compiled. Time will tell!
If it helps, you can easily find the target job's name or ID via the JCB, then youd at least know youve got the right job to work with. Of course, doing that from BASIC is as iffy as a bamboo spaceship, as youre entirely at the mercy of an environment you cant control. It might not kill you, but wheres the fun in that! As you suggest, a toolkit would be safer..


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Good Evening everyone!

And it is a good evening as I've finally got my "Loaded SuperBASIC program to Structured SuperBASIC input file" converter working. The attached zip file, created on a QL system, contains the SuperBASIC source and an executable, compiled with QLIberator. Obviously, if you need the SSB sources, you can build them yourself by loading the Basic file, then executing the executable.

I have tested this on itself, and the code it produced was then rebuild with SSB 2.7.2g and compiled. Both obj files were the same size.

I'd be grateful for any testing yoiu might want to do, however, I'd be really grateful if someone would have a go on a QDOS system, I only have SMSQ. I'd like it to be able to be run on either system. Ta.

Basic2ssb.zip
(11.82 KiB) Downloaded 6 times

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.
swensont
Forum Moderator
Posts: 322
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Structured SuperBASIC

Post by swensont »

Norman,

I gave Basic2ssb a try using sQLux. I normally have it running with the JSU rom. When I executed basic2ssb, it got to line 1060 and the program failed with a "bad paramater" error:

job 1 Basic2ssb Line 1060 PAUSE
Bad Parameter
Retry Continue Abort R/C/A

I tried with a JS rom and got the same error. I switched over to Minerva and the program was able to execute with no errors.

At first I was not sure how basic2ssb was going to work as it only asked for an output file. I could not figure out why it was not asking for an input file. After reviewing the code, I realized that the program is expecting to work on a program already loaded into SuperBasic. Once I had loaded my example program, then it worked. With no program loaded, the program seemed to run but the output file was size zero. I'm guessing you were not expecting to not have a program loaded.

My test program did not have any GOTO's, so I did a simple test:

100 print "foo"
110 go to 100

basic2ssb_obj exited with the following error:

Job 1 basic2ssb Line 2450 Q_LIB Error 13
overflow

I then switched to trying GOSUB:

100 print "foo"
110 go sub 200
120 stop
200 print "foo2"
210 return

I got the same overflow error.

I hope this helps.

Tim


User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Thanks Tim.

I'll add a check for an empty program to prevent that problem. Its interesting that goto and gosub give overflow errors extracting the line number (I presume), so I'll have t check that. In my tests, it worked fine (as all programmers say!).

Obviously I have some docs to create for it.


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: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Hi Tim,

just to confirm, the following idiotic test program does indeed work under SMSQ. I've had a look at the error lines you mentioned, and they shouldn't be causing the errors they are, however, I'm digging!

Code: Select all

100 PRINT "Foo"
110 GO SUB 200
120 :
200 PRINT "Foo 2"
210 RETurn
The output I get here is:

Code: Select all

@Line_100
PRINT "Foo"
GO SUB @Line_200
:
@Line_200
PRINT "Foo 2"
RETurn

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: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Right then, I've hopefully resolved the problems mentioned by Tim affecting QDOS systems. These were:

* Program fell over if there was not a SuperBASIC program loaded.
* Overflow errors when GOTO/GOSUB used.

I don;pt have a QDOS system, or an emulator with the JS ROM, only Minerva and SMSQ. Again, I'd be grateful for any testing on QDOS that anyone can do for me.

INSTRUCTIONS:

Load any SuperBASIC program.
Execute the Basic2ssb_obj program.
Type in the name of the output _SSB file you wish to create/overwrite. The "_SSB" extension will be added to whatever you type.
The program will continue, convert the loaded program to a format suitable for use with SSB.
After 5 seconds, the program will exit.

If you don't have a program loaded, there will be a message to that effect and the program will exit.


WHY WOULD I WANT TO DO THIS?

Good question! I wrote it because I had an old SuperBASIC program I needed to amend, and while I was at it, I wanted to make it look better. Messing about with line numbers drove me mad( or madder than I usually am!) and so this utility was born. I was able to edit my code, move sections around, copy stuff and such like then recompile (!) it with SSB to get a new, better, version.

DOWNLOAD THE CODE & SOURCE

I'll be putting this on the SinclairQL github at some point, but only when it's fully working on SMSQ and QDOS. I think I've got all the bits that SMSQ provided converted to run on either system, but I can't test it properly myself.

Basic2ssb.zip
(12.15 KiB) Downloaded 8 times

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.
swensont
Forum Moderator
Posts: 322
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Structured SuperBASIC

Post by swensont »

Norman, here is the results of my testing the latest version:

Minerva ROM:
10 print "foo"
20 go to 10

pass 1...
GO TO -1.148296e80 at Line 20
Pass1 completed.
Table build complete
Decoding loaded program...

Fails with:
Job 1 Basic2ssb Line 4680 HEX$
overflow

10 print "foo"
20 go sub 100
30 stop
100 print "foo2"
110 return

This works, but the resultant code is wrong:

PRINT "foo"
GO SUB @Line_-1.421476e107STOP
print "foo2"
RETern

It looks like with Minerva the line number references in the GOTO is being miscalculated.

JS/JSU ROM:

The GOTO is correctly calculated from the display on the screen:

GO TO 10 at Line 20

But the program exits with this message:
Job 1 Basic2ssb Line 1130 PAUSE
bad parameter

Tim


User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Morning Tim.

Interesting. Line numbers are integers, and less than 32,768 so that floating point value at line 20 is weird. I know in the program file, references to line numbers in GOTO, GOSUB, RESTORE are floats. I wonder if Minerva floats are different to QDOS/SMSQ, they shouldn't be though.

HEX$ is an SMSQ function. I need to fix that.

The PAUSE thing is from a line like:

Code: Select all

PAUSE #channel, 250
Which I've got rid of now. So that's one out of the way! But I wonder why PAUSE doesn't like parameters.


Appreciate the help Tim, thank you.

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
pjw
QL Wafer Drive
Posts: 1607
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Structured SuperBASIC

Post by pjw »

NormanDunbar wrote: Sat Apr 26, 2025 6:14 am <>
HEX$ is an SMSQ function. I need to fix that.
Apologies for wading in here, but HEX$ is a TK2 function.
NormanDunbar wrote: Sat Apr 26, 2025 6:14 am The PAUSE thing is from a line like:

Code: Select all

PAUSE #channel, 250
Which I've got rid of now. So that's one out of the way! But I wonder why PAUSE doesn't like parameters.
Annoying, isnt it? I also only rediscovered this recently. Thats why I added PAUSE[#channel,] [timeout] to my Q2S "compatibility toolkit". However, INKEY$ is a reasonable workaround, or BGET (also TK2) if no limit on the timeout is required.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
BSJR
Trump Card
Posts: 219
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: Structured SuperBASIC

Post by BSJR »

pjw wrote: Sat Apr 26, 2025 10:12 am
NormanDunbar wrote: Sat Apr 26, 2025 6:14 am The PAUSE thing is from a line like:

Code: Select all

PAUSE #channel, 250
Which I've got rid of now. So that's one out of the way! But I wonder why PAUSE doesn't like parameters.
Annoying, isnt it? I also only rediscovered this recently. Thats why I added PAUSE[#channel,] [timeout] to my Q2S "compatibility toolkit". However, INKEY$ is a reasonable workaround, or BGET (also TK2) if no limit on the timeout is required.
If I read the Jan Jones book correctly, PAUSE under QDOS only expects the timeout parameter and not a cannel number.

BSJR


Post Reply