Introduction to Tiny BASIC Web

Table of Contents

[NOTE: You must have Javascript enabled]
—✵—

Introduction to Tiny BASIC Web, version 0.1
©2025 by Mark Damon Hughes
cyberhole.online/basic/
Text licensed as CC BY-NC-SA Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license
Code licensed as BSD, see LICENSE.txt

Introduction

Tiny BASIC Web (TBW hereafter) is an interpreted, interactive BASIC which can be embedded in a web page. The purpose is to make interactive menus and mini-games easy to deploy. It's not a fully-baked programming environment, and not usable on command-line, both of which exist in many other places.

This is a tutorial for using it.

The current version is Level 1, version 0.5. L1 is a very minimal subset of BASIC, but it's enough to run some non-data-intensive programs.

When you start the page - cyberhole.online/basic/basic.html

You'll get a bootup logo of colored blocks, TinyBasicWeb version number, and a prompt of READY. You are now at command mode. READY happens at startup and after time-consuming (network) operations. Most commands or lines entered return you to command mode immediately.

Click on the Spec link on that page, and it'll show all the gory technical details of the language.

Type DIR (hit Enter after this and any other line I tell you to type), and you'll see a list of stored programs (actually on the server, not a real "disk"). LOAD "beer.bas" will load the "99 Bottles of Beer" program. You can type LIST to see what it looks like (the actual listing will be more verbose and shouty, because it standardizes every command), then RUN to start it. Type '9' and it prints the familiar drinking song.

1 CLS
2 INPUT "How many bottles of beer on the wall? ",b
3 LET b=(b%10000)
4 IF (b<1) THEN ?"1 or more beers!"
5 IF (b<1) THEN GOTO 2
10 LET s$="s"
11 IF (b=1) THEN LET s$=""
20 ?b;" bottle";s$;" of beer on the wall, ";
21 ?b;" bottle";s$;" of beer. Take one down, ";
22 ?"pass it around, ";
30 LET b=(b-1)
31 IF (b>0) THEN GOTO 10
40 ?"No more bottles of beer on the wall!"
99 END

Writing Programs

For short programs, you can type them in "live", just write the line number and statements, Enter, and it should silently accept it, or error. RUN when you're ready to test it.

I suggest writing longer programs in a local text editor, then pasting them into TBW (⌘V or ^V). It'll probably have errors, and the messages are kind of awful, but they should tell you where in the line an error occurred. Check the spec and this intro, and fix it, re-paste just the problem lines.

Write programs in a modular fashion, one part at a time. I usually make major blocks at 100s, minor blocks at 10s, and then increment lines in a block by 1, 2, or 5 at a time. Use GOSUB/RETURN to call subroutines, and keep a comment at the start (or one line before) each subroutine.

For example, making a puzzle game, make the puzzle generator as a subroutine at 100, a win test as a subroutine at 200, and the main loop of asking for moves is lines 1-99.

You can put testing code somewhere high like 9000, then 1 GOTO 9000 to run the test, 1 REM to disable the tests.

You can get text and program listings out (if they're short) by using copy (⌘C or ^C), but this only dumps into the Javascript console for now (JS security is weird). I'm working on it.

Converting Large BASIC

TinyBasicWeb is deliberately a very small BASIC, and L1 is smaller than you expect. BUT! You can still do most things from large BASIC, with just a few extra steps.

EOF