Tiny BASIC Web

Table of Contents

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

Tiny BASIC Web, version 0.6
©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 supports 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 lines should be at least 120 chars, maybe 256.

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.

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

Interactive Statements

Disk Operating System Statements

 

(L2)

Functions

(L2) all except RND

Graphics

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

Pixel graphics (px,py) have 4 pixels in a 2x2 grid per character, use LOC(3)*2, LOC(4)*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.

EOF