Page 4 of 5
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Fri Jul 05, 2024 10:50 am
by NormanDunbar
Morning all,
attached are the sources and executable for SSB version 2.7.2d which has had the Spanish language added as per the previous post from @badaman.
The zip file was created on a QL, not on a Linux/Windows/Mac device.
Cheers,
Norm.
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Fri Jul 05, 2024 2:24 pm
by Derek_Stewart
Hi
The updated to SSB look great.
Looking at the source code I noticed the all the FOR loops are terminated with a NEXT statement and not an ENF FOR statement.
Just re-read The SuperBasic Handbook by Jan Jones where she says the NEXT statement can terminate a loop.
Code: Select all
200 REPeat gobbledegook
210 a$ = CHR$(RND(65 TO 90))
220 PRINT a$;
230 IF a$=”A”: min=min+1: NEXT gobbledegook
240 IF a$=”Z”: max=max+1
250 NEXT gobbledegook
Which I have never used NEXT to terminate a REPeat loop.
The examples on the book have END FOR to terminate the FOR loop block.
But Jan quotes an example of a FOR loop with the NEXT statement to control the loop and the END FOR statement to mark the end the FOR construct:
Code: Select all
330 FOR k = 0 TO DIMN(arr$,1)
340 row = k: IF arr$(row)==name$:EXIT k
350 NEXT k
360 row = -1
370 END FOR k
What is the best way, or does this not matter?
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Fri Jul 05, 2024 3:43 pm
by tofro
Yes, you can use NEXT in a REPeat loop to start the next iteration prematurely (typically conditionally).
And yes, you can use NEXT to end a FOR loop - The distinction between NEXT and END FOR is more or less syntactic sugar (The proper way is In theory, to use NEXT to restart the loop prematurely (i.e., with an IF condition, typically) and use END FOR for the loop's outer termination. The interpreter will be happy with both. Turbo will complain with a warning if it finds FOR loops that are not terminated with END FOR but NEXT, however (and educate you you meant END FOR).
I personally find it a lot clearer when the outer termination is done with END FOR, and a conditional restart is done with NEXT (i.e., the intended way). That's just a lot easier to read.
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Fri Jul 05, 2024 10:57 pm
by swensont
Norman,
Thanks for picking up the torch on SSB and releasing a new version. Still nice to see others interested in SSB.
The reason for "FOR...NEXT" instead of "FOR...END FOR" is mostly due to "FOR...NEXT" being the original BASIC syntax and SuperBASIC added a new option but did not remove the original syntax.
Tim
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 11:26 am
by BSJR
tofro wrote: Fri Jul 05, 2024 3:43 pm
Yes, you can use NEXT in a REPeat loop to start the next iteration prematurely (typically conditionally).
...
There can be a small difference in use.
The NEXT will update the FOR variable, find it's out of range and terminate the loop.
The END FOR will not do that.
If you do test this variable outside the loop that must be considered.
BSJR
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 11:55 am
by tofro
BSJR wrote: Sat Jul 06, 2024 11:26 am
tofro wrote: Fri Jul 05, 2024 3:43 pm
Yes, you can use NEXT in a REPeat loop to start the next iteration prematurely (typically conditionally).
...
There can be a small difference in use.
The NEXT will update the FOR variable, find it's out of range and terminate the loop.
The END FOR will not do that.
If you do test this variable outside the loop that must be considered.
BSJR
Right, forgot that, thanks. Probably because I never check for loop variables outside the loop - I find that's a bad practice.
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 12:45 pm
by pjw
Just remember this little trap for the unwary:
Code: Select all
100 CLS
102 FOR i = 1 TO 7
104 i = 8: NEXT i
106 PRINT 'Uh oh'
108 END FOR i
110 :
This behaviour is probably more like what was expected
Code: Select all
100 CLS
102 FOR i = 1 TO 7
104 i = 8: NEXT i: PRINT 'ok': EXIT i
106 PRINT 'Uh oh'
108 END FOR i
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 2:20 pm
by NormanDunbar
swensont wrote: Fri Jul 05, 2024 10:57 pm
Norman,
Thanks for picking up the torch on SSB and releasing a new version. Still nice to see others interested in SSB.
Hi Tim, no problem. I was a bit worried that you might object! I was wondering if you would have any objections to putting the source up on the Sinclair QL GitHub?
If you have no objections to me doing so, I'll get it sorted. I can do different releases for the different versions from 2.7.2 as well, in case anyone needs those specific ones.
Cheers,
Norm.
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 3:38 pm
by Martin_Head
Derek_Stewart wrote: Fri Jul 05, 2024 2:24 pm
But Jan quotes an example of a FOR loop with the NEXT statement to control the loop and the END FOR statement to mark the end the FOR construct:
Code: Select all
330 FOR k = 0 TO DIMN(arr$,1)
340 row = k: IF arr$(row)==name$:EXIT k
350 NEXT k
360 row = -1
370 END FOR k
What is the best way, or does this not matter?
The Concepts section of the QL User Manual, under repetition. Says that the code between the NEXT and the END FOR, is a loop epilogue, that is only executed if the FOR range is exhausted.
So in the above example. After the END FOR k, row is the array index if name$ was found, or -1 if it was not (loop exhausted). Line 360 is only executed if k=DIMN(arr$,1).
Re: I'm looking for a S*BASIC app, possibly by Tim Swenson!
Posted: Sat Jul 06, 2024 5:39 pm
by swensont
Norman said: "I was wondering if you would have any objections to putting the source up on the Sinclair QL GitHub?"
I have no issue with that. I'm not planning on doing any further work on SSB. It has all the features that I need (and them some).
Tim