Coding SuperBasic

Helpful tips and guides, also new users can ask for help here.
User avatar
polka
Trump Card
Posts: 213
Joined: Mon Mar 07, 2011 11:43 am

Re: Coding SuperBasic

Post by polka »

Hi all ! Jedi is back ! By the way, have all the best new year !

This will not be about FORTH, but SuperBasic, Turbo and SSB etc.

When I want computation speed and low level capabilities, I don't compile SuperBasic nor assembler, I use C.
When I want interactivity (and speed) I use FORTH (on the QL, but on other engines I may use OBERON, JAVA or ComponentPascal).
When I want to play with the QL without hassle, I use SuperBasic which to my opinion was the best Basic interpreter in 1984, and still one of the most likeable up to day.

Concerning line numbers and some kind of C pre-processor looks, I was curious to read the SSB doc to see what it was about.

Quick and dirty, I wrote a 10 lines SuperBasic FuNction to add line numbers to Qed text edited files and have it LOADed or MERGEd as a plain SuperBasic program.

Code: Select all

     1 DEFine FuNction add_line_numbers(f$,first,interval)
     2 input_file$  = dev$ & f$ & "_txt"
     3 output_file$ = dev$ & f$ & "_bas"
     4 OPEN_IN#5,input_file$:OPEN_OVER#6,output_file$
     5 I = first
     6 REPeat number
     7    INPUT#5,l$ : PRINT#6,IDEC$(l,5,0);" ";l$
     8    IF EOF(#5) THEN EXIT number : ELSE l=l+interval
     9 END REPeat number
    10 CLOSE#6:CLOSE#5:RETurn l
    11 END DEFine add_line_numbers
I discovered also that most of the SSB capabilities (and more) could be attained whith the powerful SuperBasic constructs alone : but as it would be too long for this post I join a PDF showing an example of how I did it (actually a generic BOOT etc.).

I found Mistakes in the joined PDF. I erased it to correct it and will put it back soon

Jedi is sorry ! here is a new pdf with corrections and additions :
PSB1.pdf
Plain SuperBasic without line numbers
(137.22 KiB) Downloaded 244 times
Actually, I was caught in my own pitfall. As the manifest had statements (numbered outside proc. or Fncts.) which should be executed only once (like all the lresps.), I wanted to erase this part of code immediately after performing (with file TOOB). But merging this little file of commands had to be the first numbered statement outside any proc. or fn. At line 32741, it wasn't. So I just had to place it somewhere else (actually, at the end of CFORMS_txt).

Indeed, even when coding with SuperBasic without line numbers, you have ways to avoid using GOTO without requiring labels like with SSB.

Moreover, I did not find in the SSB doc any way to substitute for DATA RESTORE READ constructs without line numbers ? Which to my opinion are more useful than GOTO.

Bye, POLKa
Last edited by polka on Sun Mar 03, 2024 12:35 pm, edited 3 times in total.


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 213
Joined: Mon Mar 07, 2011 11:43 am

Re: Coding SuperBasic

Post by polka »

Hi all !

Today it is snowy and rainy and windy in the Alps, so instead of skiing I could quickly correct my post above. new pdf !

Bye ! POLKa


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 213
Joined: Mon Mar 07, 2011 11:43 am

Re: Coding SuperBasic

Post by polka »

Hi all,

Something maybe to discuss at our meeting in Dormagen :
anylangy.pdf
Forth programming SuperBasic
(264.1 KiB) Downloaded 296 times
Bye


May the FORTH be with you !
POLKa
swensont
Forum Moderator
Posts: 325
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Coding SuperBasic

Post by swensont »

Polka wrote:

> Moreover, I did not find in the SSB doc any way to substitute for DATA RESTORE READ constructs without line numbers ? Which to my opinion are more useful than GOTO.

SSB Labels work with the RESTORE statement as well as with GOTO's. Here is an example:

Code: Select all

@label
   data 10,20,30,40

   restore @label

   for x = 1 to 4
      read y
      print y
   next x
Which gets converted to:

Code: Select all

100    data 10,20,30,40
110    restore 100
120    for x = 1 to 4
130       read y
140       print y
150    next x


Post Reply