Tiny BASIC Web

Table of Contents

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

Tiny BASIC Web, version 0.8
©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.

Level 1 supported only numeric or string variables of 1-2 chars, string constants. No arrays, functions, labels, or optional items. RND is a pseudo-variable.

Level 1 terminal only supports one physical line for commands or inputs, so maximum 63 chars in my setup. Whether this will be improved in Level 2, or only in uploaded scripts, remains to be seen. Ideally it should support lines of at least 120 chars, maybe 255.

Level 2 is as below.

Usage

Just type. In command mode (after READY or any successful command), up to a screen width of characters can be entered.

Paste (⌘V or ^V) works, but is subject to the same rules as keyboard use: Wrap your lines at 63 chars.

To get your program out, use LLIST, and copy from the "printer" listing that opens below.

You can find out what files exist with DIR, and choose to load one with LOAD "filename".

Once you have a program entered, type RUN.

NEW or reload the page to get a blank BASIC again.

While running, you can hit ^Z to break out of the program!

Known Issues

Embedding

<html>
<head>
<title>TinyBasicWeb</title>
<link href='../style.css' rel='stylesheet' type='text/css' />
<script src='../js/mdhutil.js'></script>
<script src='../js/terminal.js'></script>
<script src='../js/tbasicweb.js'></script>
</head>
<body onload='tbasicwebinit("terminal", [64,24], [15,24], "myprog.bas")'>
<div id='terminal'></div>
</body>
</html>

You can start with no program ("boot to READY") by changing "myprog.bas" to null.
Or use a 'run' URL parameter as your BASIC program, change "myprog.bas" to
new URL(document.location).searchParams.get("run"))

To pack the canvas size correctly, pick sizes you like, run it. The browser console will show Actual charsize=X. Then change the ones you give in the function, and reload. My initial guess of [64,24], [14,24] produced Actual charsize=14.40234375, so I changed width to 15.

Syntax

Statements

(L2)

Interactive Statements

(L2)

Disk Operating System Statements

 

(L2)

Functions

Parentheses are optional for 0 arguments, so RND can be treated as a "pseudo-variable", giving a new random number every time it is referenced.

(L2)

Graphics

Low-rez mixes character and "pixel" graphics. Characters are placed on the screen from 0,0 to LOC(2), LOC(3) positions. Use PRINT AT(x,y) to specify location.

Pixel graphics (px,py) have 4 pixels in a 2x2 grid per character, use LOC(2)*2, LOC(3)*2 to get screen size in pixels.

PIX$(n) lets you mix text and graphics, or store a line of pixels in a string.

Drawing characters or pixels offscreen is ignored.

Statements:

Functions:

EOF