Oli4
Posts: 10
Joined: Sun Jun 02, 2019 9:01 am

Searching for BASIC

Sun Jun 02, 2019 12:06 pm

I'm searching for a BASIC language that can be run in the terminal like a C64 and also has the 10 ... 20 ... etc. lines. The one I found the most fitting is TinyBasic, but i can't find it for the pi. So I'm hoping that someone knows how i can download TinyBasic or an alternative.

jahboater
Posts: 4846
Joined: Wed Feb 04, 2015 6:38 pm

Re: Searching for BASIC

Sun Jun 02, 2019 12:39 pm

Some links, there are probably others ....
My choice would be BBC BASIC, or possibly write my own 1964 Dartmouth BASIC interpreter (for fun and historical interest - relatively easy with a modern parser generator).

BBC BASIC
viewtopic.php?f=34&t=238187

ScriptBasic
viewtopic.php?f=34&t=238001

Long discussion about BASIC and other things:-
viewtopic.php?f=62&t=227343

In those threads you will see references to countless versions of BASIC, hopefully some of which might be suitable.

User avatar
RichardRussell
Posts: 592
Joined: Thu Jun 21, 2012 10:48 am

Re: Searching for BASIC

Sun Jun 02, 2019 2:05 pm

jahboater wrote:
Sun Jun 02, 2019 12:39 pm
My choice would be BBC BASIC
Mine too, naturally (!), but the OP did ask for it to "run at the terminal" and he may feel that it does not qualify for that reason. Whilst you can run BBC BASIC for SDL 2.0 as a terminal-like session, it doesn't have the necessary functionality to enter and edit programs that way; the assumption is that you will use one of the IDEs for that.

Given some of the comments I've received here, though, I do wonder if that was a poor decision on my part and that perhaps I should add a retro-style code entry/editing capability. It wouldn't be too difficult - it's only reinstating what earlier versions had anyway, and the line-number capability is already there - although it's not something I would ever choose to use myself.

User avatar
scruss
Posts: 2633
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Searching for BASIC

Sun Jun 02, 2019 2:14 pm

Oli4 wrote:
Sun Jun 02, 2019 12:06 pm
I'm searching for a BASIC language that can be run in the terminal like a C64 and also has the 10 ... 20 ... etc. lines.
How about cbmbasic? It is C64 BASIC and runs in a terminal. It's supplied as source, but it's a fairly easy build.

It's also terminal only, no graphics at all.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Searching for BASIC

Sun Jun 02, 2019 3:39 pm

Vintage BASIC is well done and worth a peek.

jahboater
Posts: 4846
Joined: Wed Feb 04, 2015 6:38 pm

Re: Searching for BASIC

Sun Jun 02, 2019 3:59 pm

RichardRussell wrote:
Sun Jun 02, 2019 2:05 pm
Given some of the comments I've received here, though, I do wonder if that was a poor decision on my part and that perhaps I should add a retro-style code entry/editing capability. It wouldn't be too difficult - it's only reinstating what earlier versions had anyway, and the line-number capability is already there - although it's not something I would ever choose to use myself.
Or perhaps a half-way solution where you just take a single BBC BASIC source file as an argument - like most interpreters provide.

python hello.py
node hello.js
gst hello.st
bash hello.sh
scriba hello.sb

bbcbasic hello.bas

Although the retro line editor would clearly be fun, most people can edit source files with their choice of text editor.
It should accept "#!/usr/local/bin/bbcbasic" of course, even if its a special case for the first line.

Oli4
Posts: 10
Joined: Sun Jun 02, 2019 9:01 am

Re: Searching for BASIC

Sun Jun 02, 2019 5:03 pm

scruss wrote:
Sun Jun 02, 2019 2:14 pm
How about cbmbasic? It is C64 BASIC and runs in a terminal. It's supplied as source, but it's a fairly easy build.

It's also terminal only, no graphics at all.
Thanks thats exactly what I'm looking for, but I don't really know how to install or run it.

Oli4
Posts: 10
Joined: Sun Jun 02, 2019 9:01 am

Re: Searching for BASIC

Mon Jun 03, 2019 2:55 am

Oli4 wrote:
Sun Jun 02, 2019 5:03 pm
Thanks thats exactly what I'm looking for, but I don't really know how to install or run it.
Never mind I found a tutorial on YouTube https://youtu.be/cBFoW4j1P1c

User avatar
RichardRussell
Posts: 592
Joined: Thu Jun 21, 2012 10:48 am

Re: Searching for BASIC

Mon Jun 03, 2019 8:23 am

jahboater wrote:
Sun Jun 02, 2019 3:59 pm
Or perhaps a half-way solution where you just take a single BBC BASIC source file as an argument - like most interpreters provide.
That is already (and always has been) implemented. Indeed that is how the IDEs run the current BASIC program, they spawn the interpreter / run-time engine specifying the filename of a temporary copy of the program. The only caveat is that, as is usual in BBC BASIC, the supplied file must be in internal (tokenised) format, i.e. with a .bbc extension, not plain text. There is a workaround for that here.
python hello.py
node hello.js
gst hello.st
bash hello.sh
scriba hello.sb
bbcsdl hello.bbc
bbcsdl basrun.bbc hello.bas

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Searching for BASIC

Tue Jun 04, 2019 8:43 am

ScriptBasic has 4 ways to run your code.

1. Text file
2. Tokenized binary file (great if you want to distribute your app without source)
3. Compiled as a C program

Code: Select all

jrs@jrs-laptop:~/sb/examples/test$ cat hello.sb
PRINT "Hello World\n"
jrs@jrs-laptop:~/sb/examples/test$ scriba -Co hello.c hello.sb
jrs@jrs-laptop:~/sb/examples/test$ cat hello.c
/* FILE: hello.c */
unsigned long ulGlobalVariables=1;
unsigned long ulNodeCounter=4;
unsigned long ulStartNode=4;
unsigned long ulStringTableSize=21;
unsigned char szCommandArray[] ={
0x8D, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00 };
char szStringTable[]={
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 
0x72, 0x6C, 0x64, 0x0A, 0x00, 
0x00 };
#ifdef WIN32
main(int argc, char *argv[]){stndlone(argc,argv);}
#else
char **_environ;
main(int argc, char *argv[], char *env[]){stndlone(argc,argv,env);}
#endif
/*End of file hello.c */
jrs@jrs-laptop:~/sb/examples/test$ 
You would then compile this with a link to libscrba.a which would result in a runtime executable of about 12KB.


4. Standalone executable - Scriba creates a copy of itself and apends the tokenized script with the name you provide. No compiling needed.

Code: Select all

jrs@jrs-laptop:~/sb/examples/test$ /usr/local/bin/scriba -Eo hello hello.sb
jrs@jrs-laptop:~/sb/examples/test$ chmod 755 hello
jrs@jrs-laptop:~/sb/examples/test$ ./hello
Hello World
jrs@jrs-laptop:~/sb/examples/test$ ls -l hello
-rwxr-xr-x 1 jrs jrs 793793 Jun  4 02:17 hello
jrs@jrs-laptop:~/sb/examples/test$ 

User avatar
scruss
Posts: 2633
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Searching for BASIC

Tue Jun 04, 2019 12:08 pm

ScriptBasic wrote:
Tue Jun 04, 2019 8:43 am
ScriptBasic has 4 ways to run your code. …
Doesn't quite meet the OPs requirement of
… the 10 ... 20 ... etc. lines
cbmbasic, for all its limitations, gets installed on almost every machine I use. I'm glad someone put a video out there, but my installation procedure goes something like:

Code: Select all

sudo apt install build-essential git
git clone https://github.com/mist64/cbmbasic.git
cd cbmbasic
make
mkdir -p ~/bin
cp cbmbasic ~/bin
cd ..
rm -rf cbmbasic/
You might have to log out and back in again to get ~/bin in your path. Alternatively, you can do this once to get immediate access:

Code: Select all

export PATH=${PATH}:~/bin
The biggest annoyance with cbmbasic is that it saves programs in tokenised binary format. I'd normally recommend the petcat command from the VICE emulator, but I don't see that in the Raspbian repos.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Searching for BASIC

Fri Jun 07, 2019 5:50 am

Code: Select all

10 LET A$ = "ScriptBasic"
20 PRINT UCASE(MID$(A$, 7))
99 END
If vintage BASIC is your cup of tea.

User avatar
RichardRussell
Posts: 592
Joined: Thu Jun 21, 2012 10:48 am

Re: Searching for BASIC

Fri Jun 07, 2019 8:39 am

ScriptBasic wrote:
Fri Jun 07, 2019 5:50 am
If vintage BASIC is your cup of tea.
BASICs that treat 'line numbers' like labels tend not to support a couple of features that 'traditional' line-numbered BASICs do:

  1. The ability to RENUMBER the program (e.g. to make space for new lines) whilst automatically adjusting references to lines whose numbers have changed.
  2. The option of omitting the GOTO in IF statements, such as IF condition THEN 100 (rather than THEN GOTO 100).
  3. The ON ... GOTO and ON ... GOSUB statements, which take a list of line numbers to specify the destinations.

BBC BASIC supports all these features, does ScriptBasic?

Heater
Posts: 13930
Joined: Tue Jul 17, 2012 3:02 pm

Re: Searching for BASIC

Fri Jun 07, 2019 8:51 am

I think what we need here is a good ol'BASIC. The Pi should power up into a full screen terminal like interface. Like our old C64's, Sinclair's, TRS-80s did. Except this would allow for a lot more lines and characters per line. No X Windows junk, just display straight into the frame buffer.

From there one could immediately start typing BASIC as we did in days of yore.

Whatever graphics primitives are available could be more sophisticated of course.

There would be some command to get a Linux shell running when one wants get more serious.
Memory in C++ is a leaky abstraction .

jahboater
Posts: 4846
Joined: Wed Feb 04, 2015 6:38 pm

Re: Searching for BASIC

Fri Jun 07, 2019 10:52 am

You mean with "init=xxxbasic" in cmdline.txt

init=/usr/bin/python

works (without the fancy framebuffer of course) and the Pi boots directly into the Python prompt, without systemd or anything else starting up.

User avatar
scruss
Posts: 2633
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Searching for BASIC

Mon Jun 10, 2019 8:35 am

Heater wrote:
Fri Jun 07, 2019 8:51 am
I think what we need here is a good ol'BASIC. The Pi should power up into a full screen terminal like interface.
There's always MMBASIC, but you didn't like it: viewtopic.php?t=212334
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Heater
Posts: 13930
Joined: Tue Jul 17, 2012 3:02 pm

Re: Searching for BASIC

Mon Jun 10, 2019 10:01 am

I'd have to be desperate to have to use a non Open Source BASIC.

You found many other reasons to not like MMBASIC : viewtopic.php?t=212334#p1309596
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Searching for BASIC

Tue Jun 11, 2019 4:28 am

RichardRussell wrote:
Fri Jun 07, 2019 8:39 am
ScriptBasic wrote:
Fri Jun 07, 2019 5:50 am
If vintage BASIC is your cup of tea.
BASICs that treat 'line numbers' like labels tend not to support a couple of features that 'traditional' line-numbered BASICs do:

  1. The ability to RENUMBER the program (e.g. to make space for new lines) whilst automatically adjusting references to lines whose numbers have changed.
  2. The option of omitting the GOTO in IF statements, such as IF condition THEN 100 (rather than THEN GOTO 100).
  3. The ON ... GOTO and ON ... GOSUB statements, which take a list of line numbers to specify the destinations.

BBC BASIC supports all these features, does ScriptBasic?
ScriptBasic doesn't support DATA/READ either. SB tries to accommodate vintage BASIC syntax but there is a limit before it would affect its traditional BASIC format.

ZXDunny
Posts: 117
Joined: Sun Jul 08, 2012 7:57 pm

Re: Searching for BASIC

Tue Jun 11, 2019 1:44 pm

Heater wrote:
Fri Jun 07, 2019 8:51 am
I think what we need here is a good ol'BASIC. The Pi should power up into a full screen terminal like interface. Like our old C64's, Sinclair's, TRS-80s did. Except this would allow for a lot more lines and characters per line. No X Windows junk, just display straight into the frame buffer.

From there one could immediately start typing BASIC as we did in days of yore.

Whatever graphics primitives are available could be more sophisticated of course.

There would be some command to get a Linux shell running when one wants get more serious.
<ahem>

screenshot_192.png
screenshot_192.png (95.11 KiB) Viewed 1997 times
The latest build is not yet available for the Pi, but there's only one source file to modify before it will build. I'll have to get my Pi connected up this coming weekend and have at it. I suspect it might run quite well on a Pi3B.

It can start up fullscreen (I have it running that way on a GPD Pocket), uses proper actual line numbers, has loads and loads of graphics stuff, sound stuff, and various other goodies and is based heavily on vintage Sinclair BASIC. Scriptbasic insists that it's a "museum basic" in general, which is fine because that's what it is. It also has a full command line functionality via BASIC commands so scripting is as easy as writing a new program.

And yes, it's a toy, but it's my toy. I don't expect masses of users, but the ones that do follow it seem to love it.

More videos of it doing stuff here: https://www.youtube.com/user/ZXSpin/videos

D.

User avatar
John_Spikowski
Posts: 1614
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Searching for BASIC

Tue Jun 11, 2019 5:42 pm

Hi D,

Glad to see you here on the RPi forum. I would be happy to setup a child board on RaspberryBASIC.org forum for your project.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Searching for BASIC

Sat Jun 29, 2019 9:31 pm

Oli4 wrote:
Sun Jun 02, 2019 12:06 pm
I'm searching for a BASIC language that can be run in the terminal like a C64 and also has the 10 ... 20 ... etc. lines. The one I found the most fitting is TinyBasic, but i can't find it for the pi. So I'm hoping that someone knows how i can download TinyBasic or an alternative.
BBC BASIC V aka ARM BASIC, runs on RISC OS on every version of the Raspberry Pi (not on the 4b yet). Known well to be one of the better interpreted BASIC versions out there, and very fast. Also it is a component of RISC OS and always has been, so you can write just about any kind of program with it, including a full multitasking 3D game running in a window, or a word processor, or whatever.

If you wish to compile your code later there are a few good options for ARM BASIC compilers that run in RISC OS on the RPi and produce ARMv8 compatible code, that will also run on anything down to the ARMv2. !ABC is probably the most popular ARM BASIC compiler.

Now if you are looking for something that will run on Linux or BSD or Plan9 or some other RPi OS, I can not think of any that comes anywhere near the performance of ARM BASIC, sorry.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Searching for BASIC

Sat Jun 29, 2019 9:48 pm

Heater wrote:
Fri Jun 07, 2019 8:51 am
I think what we need here is a good ol'BASIC. The Pi should power up into a full screen terminal like interface. Like our old C64's, Sinclair's, TRS-80s did. Except this would allow for a lot more lines and characters per line. No X Windows junk, just display straight into the frame buffer.

From there one could immediately start typing BASIC as we did in days of yore.

Whatever graphics primitives are available could be more sophisticated of course.

There would be some command to get a Linux shell running when one wants get more serious.
Or build an entire OS around BASIC. Start with a working Frame buffer, add text drawing support, add USPi for keyboard and mouse support, get the interpreter (and a compiler as well) up and running, add in a graphical window manager, and BASIC commands to support it (as well as call points for native code to use all the features).

That would be the best thing to see on the RPi. If could add networking support and port Netsurf you would have a complete OS good for day to day use (as any program you need would be easier to write than most other platforms).

For something like that, I would recommend beginning with Commodore BASIC v10, add in support for parameterized functions/procedures with local private variables, add in support for structured data types, and add in support for pointers, that would be a good starting point. For the Window Manager/GUI environment I would recommend looking at the windowing and menu commands of MS-QuickBASIC for the Macintosh as well as those of AmigaBASIC as a rough guideline, as we are speaking of evolving a dialect of BASIC that evolved from MicroSoft 8K BASIC. For dynamic library support I would look at the commands of AmigaBASIC that provided such support.

Though definitely start from the syntax of Commodore BASIC v10, and keep it line numbered in nature (even if you do not need to use the line numbers for anything, like in BBC BASIC V).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

ZXDunny
Posts: 117
Joined: Sun Jul 08, 2012 7:57 pm

Re: Searching for BASIC

Sat Jun 29, 2019 9:56 pm

DavidS wrote:
Sat Jun 29, 2019 9:48 pm
<blah>
Honestly, it's like I'm invisible or something :D

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Searching for BASIC

Sat Jun 29, 2019 10:02 pm

I almost forgot that would need to implement a screen editor if one were to go that way.
ZXDunny wrote:
Sat Jun 29, 2019 9:56 pm
DavidS wrote:
Sat Jun 29, 2019 9:48 pm
<blah>
Honestly, it's like I'm invisible or something :D
I think it is to the limits of Sinclair BASIC. I also think people like the feel of the old fashioned screen editors from the 8-bit age of home computers.

Though you have me curious, as I really like BASIC. What does it minimally require to run (can it be plopped onto bare metal with just Frame Buffer and Keyboard support)?

I am always interested in looking at a different BASIC implementation, and that is one I have never played with.

Also what is the URL for the source? As it is an old fashioned BASIC that can run on the RPi I must assume ARM Assembly as the language of implementation (as traditional 8-bit style BASIC were only ever implemented in Assembly language, often requiring hand porting to other platforms).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

ZXDunny
Posts: 117
Joined: Sun Jul 08, 2012 7:57 pm

Re: Searching for BASIC

Sat Jun 29, 2019 10:20 pm

DavidS wrote:
Sat Jun 29, 2019 10:02 pm
I almost forgot that would need to implement a screen editor if one were to go that way.
ZXDunny wrote:
Sat Jun 29, 2019 9:56 pm
DavidS wrote:
Sat Jun 29, 2019 9:48 pm
<blah>
Honestly, it's like I'm invisible or something :D
I think it is to the limits of Sinclair BASIC. I also think people like the feel of the old fashioned screen editors from the 8-bit age of home computers.
But Sinclair BASIC was in no way anything like as limited as C64 BASIC was. I mean, literally.
Though you have me curious, as I really like BASIC. What does it minimally require to run (can it be plopped onto bare metal with just Frame Buffer and Keyboard support)?
If you want to port it to a different architecture you only have to modify one file - currently in linux it uses SDL to provide a framebuffer. Sound requires the bass libs (simply because I work in audio programming for a living and can't be arsed to implement audio). With no libs then audio is simply disabled. So the absolute minimum would be a pointer to a framebuffer and some way to call the keyup/down handlers. If you have some 3D graphics acceleration via OpenGL then you can have nice scaling to full screen.
I am always interested in looking at a different BASIC implementation, and that is one I have never played with.
It's been available for the pi for many years now. I've not rebuilt it recently as I tend to spend most of my time actually writing it. I've made huge changes to the Windows build over the last year or so that will require handling properly - but I lack time at present to port it to the Pi.
Also what is the URL for the source? As it is an old fashioned BASIC that can run on the RPi I must assume ARM Assembly as the language of implementation (as traditional 8-bit style BASIC were only ever implemented in Assembly language, often requiring hand porting to other platforms).
Why assume asm? It's written in object-pascal so can be built with FPC. Due to recent changes to the editor, it won't run on the pi until I port the interface unit (that's the file I was talking about earlier) - a lot has changed with the compositor. As the pi isn't an 8bit CPU there's no real reason to use assembly language for anything like this.

It's a bytecode interpreter and it's pretty quick compared to other interpreters.

A gallery of things it can do:

https://www.youtube.com/user/ZXSpin/videos

None of it is hardware accelerated, it's all done in software via the interpreter.

Return to “Other programming languages”