Coding SuperBasic

Helpful tips and guides, also new users can ask for help here.
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Coding SuperBasic

Post by dilwyn »

Andrew wrote: Tue Nov 22, 2022 2:45 pm
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
Have been meaning to try this - there are some editor syntax highlighting utils for various editors tucked away at the end of my BASIC Programs page http://www.dilwyn.me.uk/basic/index.html including Notepad++

I'll certainly be checking such systems if I do get round to writing my editor to see what ideas I can spin off to my effort. The only reason I was hoping to do this is to get an editor for my own use with SSB running on a QL, which does what I find I either can't or find inconvenient atm.


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 »

Thanks Dilwyn. It sounds interesting and I shall be looking forward to seeing it in the flesh.

I am very aware of the problem of getting from idea to reality! I shall wait patiently.

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.
Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Coding SuperBasic

Post by Derek_Stewart »

Hi,

The problrm with using non-QL editors, is that this only works on emulators!

I am quite happy using QD with SBASIC/QBASIC, HyperHelp system, to give defintion of SBASIC keywords. The only thing missing is syntax highlighting, checking.

Not too bothered by syntax checking, as the interpreter does that.

Syntax highlighting, is a ommission I would like, but wait, MicroEmacs can do syntax highlighting, it also can use SSB and with a little bit of confuguration, MicroEmacs can execute SBASIC programs.


Regards,

Derek
7alken
ROM Dongle
Posts: 18
Joined: Tue Apr 18, 2023 2:23 am

Re: Coding SuperBasic

Post by 7alken »

hi guys, as I am using my tiny simplification of SSB now for QL(X)Commander code mods, I am also on background thinking about some extensions to SSB concept (it is somewhat possible to peek into it in what I shared to QLCommander thread); would be nice to have syntax coloring editor for such SSB code, without line numbers, similar as internal ED, but enforcing indentation, allowing copy/paste, so I have this also in mind, somewhere in background, ya ... but now I am using with QPC2 and the shared "drv1" the SciTE editor (defacto Notepad++ core "scintilla" C component), this is okay for now

BUT - BIGGER problem I have now is to identify some special SuperBasic "editing" commands, how to find them (I know ED, LIST, DLINE, RENUM, LOAD, SAVE, MERGE ... but can't now find some comprehensive doc which lists ALL of such "special/editing" commands not usable as much in code (without TYPE_IN or so), as I am looking for some "SEARCH", some "LIST/FIND procedurename" to find line where something is defined or so - in win/desktop SciTE I can do simply "find", but in QL SB window (ED + cmdline), where I have now generated (unimportant) line numbers, I dont know where quickly get on which line number is function/procedure defined to bring "ED line" to move there ... I think I saw it somewhere, as such "search" commands may exist, may be in some toolkits(?)

- kindly please, is something like this possible??
Petr

here for reference is my current simplified "CompileSsb2Bas" (no @labels, no #include, double apostrof '' for comments)
(I wish to use mostly functions instead of procedures, always returning something/err (not ignorable as in C, ya?), always in "fncall()" form, want to allow "SSB multiline" based on such fncall(...) lines sequence, maybe add later "var++, var--" post in/de-crements and few most used tiny things to even simplify coding - its all experimental towards my own other project too; there may occur also something like "SSC" form soon, where SB constructs may be modified for usage of "curly braces" to "mimic simple C" as much as possible, while staying still SSB/SB transpilable easily (usable in VSCode or refactorings/renamings of funcs/vars) - one thing I want also to change is having "integers as default", without the "%" suffix (as I need mostly integers and strings only, and the "%" suffix everywhere complicates reading of code), with "%" suffix generated only in final SB code - for such form of SSB/SSC can then be useful native QL syntax coloring editor similar to "ED" (but this later, similar situation as you have with time... AND probably/sure, there are REAL SB PROs who can do this... I am still trying to grasp it all for as easy as possible programming)

Code: Select all

''-----------------------------------------------------------
''QLXC IDE simplified SSB to BAS conversion
''- missing support for @Lables and #include, now !!!
defproc CompileSsb2Bas(ssb_filename$, bas_filename$)
  local i, x$

  ierr = fop_in(#10, ssb_filename$)
  oerr = fop_over(#11, bas_filename$)
  print #11, "1 rem &&SSBGEN"
  linenum = 10
  repeat linenum
    input #10, in$
    if EOF(#10) then exit
    if (chr$(38) & chr$(38) & "QLCGEN") instr in$ then exit
    out$ = in$
    if in$ = "" then out$ = ":"
    pos = (chr$(39) & chr$(39) instr in$)
    ''or ("##" instr in$) or ("//" instr in$) + odd '
    if pos > 0
      if pos > 1
        for i = 1 to pos : if in$(i) <> " " then exit : next i
        if i < pos
            comment$ = ": rem"
        else
            comment$ = "rem "
        endif
        out$ = in$(1 to pos - 1) & comment$
      else out$ = "rem "
      endif
      out$ = out$ & in$(pos to)
    endif
    print #11, linenum & " " & out$
    linenum = linenum + 2
  endrepeat
  close #10
  close #11
enddef



swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Coding SuperBasic

Post by swensont »

Ok, I swear that I've not paid Dilwyn or Norman or anyone else to mention SSB. :-)

SSB was first created in 1991. It just took some time to get some attention.

I like to view SSB as a pre-processor, as the inspiration was the C preprocessor (include statements, conditional compilation, etc).

For an editor, I usually use QED as it is simple and the first QL editor that I really used (it and ED). MicroEmacs is powerful and I did some serious QL programming I would use it.

Tim


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 »

swensont wrote:Ok, I swear that I've not paid Dilwyn or Norman or anyone else to mention SSB. :-)
I'm happy to mention SSB without payment!

I am hooked on it for writing SuperBASIC code, and even more so after I fixed a bug and added a couple of changes which suited my way of coding, even if Tim wasn't too keen! ;)

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
polka
Trump Card
Posts: 196
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 20 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: 196
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
Post Reply