This manual documents the web-based TRS-80 Model 4 TinyBASIC Fully Loaded emulator. It is written in the style of an early-1980s computer reference, but it accurately describes the features implemented by this browser emulator. The system accepts numbered BASIC program lines, direct commands, numeric and string expressions, arrays, DATA statements, subroutines, loops, screen-positioned output, and ASCII program files. Use the emulator as a programming laboratory: type a line, list it, run it, interrupt it, modify it, and save it back to your local computer.
PRINT "RADIO SHACK TRS-80 MODEL 4"
PRINT "READY"The manual is organized as a tutorial, command reference, programming guide, troubleshooting handbook, and collection of runnable examples. Use the search box at the top to locate a statement such as DIM, PRINT, BREAK, RND, or GOSUB. The table of contents links to each page. Printed output is formatted as a multi-page reference manual. Features marked as emulator extensions are convenient browser features and are not claimed to be exact copies of every historical Model 4 BASIC implementation.
Open the emulator page and allow the simulated boot sequence to complete. Click or tap the green display before typing. The READY prompt indicates that the command processor is waiting. A line that begins with a number is stored in program memory. A line without a number is executed immediately as a direct command. RESET / BOOT clears the display and restarts the simulated system; it does not represent a physical power cycle.
10 PRINT "HELLO"
20 END
RUNThe greater-than prompt is the input point. Direct statements are useful for calculations and experiments. Numbered lines build a program. LIST displays the stored program. RUN begins execution at the lowest numbered line. NEW removes all program lines. CLEAR resets variables and runtime stacks but leaves the program text intact.
PRINT 2+2
A=25
PRINT SQR(A)Type a line number followed by a BASIC statement. Re-entering the same number replaces the old line. Entering a number by itself deletes that line. Program lines are sorted numerically, so you may enter them in any order. Leave gaps such as 10, 20, 30 so additional lines can be inserted later. The current emulator also provides cursor-aware command-line editing: Left/Right move through the line, Home/End jump to either end, Backspace and Delete remove characters, and normal typing inserts characters at the cursor. EDIT n recalls stored BASIC line n onto this editable command line.
10 PRINT "FIRST"
30 PRINT "THIRD"
20 PRINT "SECOND"
LIST
20Direct mode executes an unnumbered statement immediately. Program mode stores numbered lines for later execution. Most statements work in either mode, although GOTO and GOSUB require a stored program target. Direct mode is especially useful for testing expressions, checking functions, and inspecting variables.
PRINT FACT(6)
PRINT SIN(PI/2)
PRINT RANDINT(1,6)RUN resets runtime variables and arrays, scans DATA statements, clears FOR/NEXT and GOSUB stacks, and begins execution at the first stored line. When the program reaches END or passes the final statement, READY is displayed. A running program can be stopped with BREAK PROGRAM, the on-screen BREAK key, Esc, or Ctrl+C.
Starts execution of the numbered BASIC program currently stored in emulator memory.
RUN| Element | Description |
|---|---|
RUN | Direct command; it does not take a line-number argument in this emulator. |
RUN prepares a fresh execution environment, clears scalar variables and arrays, resets DATA, FOR/NEXT, and GOSUB state, scans DATA statements, and begins with the lowest numbered program line. Program text remains unchanged. Execution ends normally after END or after the final statement, and it can be interrupted by BREAK.
The original runnable examples are retained below.
10 PRINT "RUNNING"
20 GOTO 10
RUNBREAK is the emergency stop for a running BASIC program. The large BREAK PROGRAM button, the virtual BREAK key, Esc, and Ctrl+C all request an interrupt. The interpreter checks for the interrupt between statements and while pacing long loops or PAUSE delays. BREAK also cancels a program waiting at INPUT. The display reports *** BREAK *** followed by READY. BREAK does not erase the stored program.
Stops a running program without erasing its numbered lines.
BREAK PROGRAM buttonVirtual keyboard: BREAKKeyboard: EscKeyboard: Ctrl+C| Element | Description |
|---|---|
BREAK request | An interrupt flag checked between statements, during paced loops, during PAUSE, and while INPUT is waiting. |
BREAK is the emergency recovery mechanism for an accidental infinite loop or a program that is producing excessive output. It clears active runtime stacks and cancels pending input. The stored listing stays available for inspection, correction, and another RUN.
The original runnable examples are retained below.
10 PRINT "PRESS BREAK"
20 GOTO 10
RUNLIST displays every stored line in ascending numeric order. The listing is plain ASCII text and corresponds to what SAVE ASCII BASIC writes to disk. LIST does not run the program or alter variables. Use it often while debugging to verify line numbers, punctuation, array subscripts, and branch targets.
Displays every stored numbered program line in ascending numeric order.
LISTLIST is the principal program-inspection command. It shows exactly the text that will be written by SAVE ASCII BASIC. Listing does not execute statements, change variables, or reset arrays.
The original runnable examples are retained below.
NEW removes all numbered program lines. It is intended for starting a new program. Save any program you wish to keep before issuing NEW. NEW does not delete files from the local computer; it only clears the emulator program memory.
Deletes all numbered BASIC lines from emulator memory so a new program can be entered.
NEWNEW affects the in-memory program only. It does not delete a previously saved .BAS file. Because browsers do not provide automatic recovery of unsaved BASIC listings, NEW should be used only after the current program has been saved or is no longer needed.
The original runnable examples are retained below.
CLEAR resets numeric variables, string variables, numeric arrays, string arrays, the DATA pointer, FOR/NEXT stack, and GOSUB stack. The numbered program remains in memory. RUN performs its own runtime reset before execution, so CLEAR is most useful while experimenting in direct mode.
Resets variables, arrays, DATA position, and active runtime stacks while preserving program text.
CLEARCLEAR initializes A through Z to zero, A$ through Z$ to empty strings, removes array definitions and values, resets the DATA pointer, and empties FOR/NEXT and GOSUB stacks. RUN performs a comparable runtime reset automatically.
The original runnable examples are retained below.
CLS clears the emulated display. Used as a program statement, it creates a clean screen before menus, games, tables, or animation. Used as a direct command, it clears the terminal and restores the prompt.
Clears the simulated terminal or screen display.
CLS10 CLSIn direct mode, CLS clears the terminal and restores the command prompt. In program mode, it clears output so menus, positioned text, or animation can begin with a clean display. CLS does not modify program lines or variables.
The original runnable examples are retained below.
10 CLS
20 PRINT @ 128,"MODEL 4 BASIC"HELP prints a compact list of implemented statements, operators, functions, arrays, disk/tape controls, file I/O, RENUM, and BREAK methods. MEM reports simulated free memory. DIR and CATALOG enumerate the currently selected virtual drive, as does FILES. BASIC and SYSTEM display period-style ready messages. These commands provide emulator conveniences and do not constitute a complete TRSDOS implementation.
Provides emulator help and period-style simulated system information.
HELPMEMDIRCATALOGBASICSYSTEM| Element | Description |
|---|---|
HELP | Displays supported commands, functions, arrays, file controls, and interrupt keys. |
MEM | Reports simulated free memory; the figure is decorative rather than a live JavaScript heap measurement. |
DIR / CATALOG | Displays a simulated drive directory. |
BASIC / SYSTEM | Displays Model 4 BASIC or TRSDOS-style ready messages. |
These commands support the atmosphere and usability of the emulator. They do not implement a complete TRSDOS file system, disk allocation map, or machine-language command environment.
The original runnable examples are retained below.
Select LOAD ASCII BASIC and choose a local .BAS or .TXT file. The browser reads the file as text, normalizes line endings, and imports numbered BASIC lines into program memory. The file never needs to be uploaded to a server. After loading, use LIST to inspect it and RUN to execute it. A valid ASCII program should contain one numbered BASIC line per text line.
Imports a plain-text BASIC listing from the local device into emulator program memory.
Select LOAD ASCII BASICChoose a plain-text file containing numbered BASIC lines| Element | Description |
|---|---|
.BAS / .TXT / other text file | The filename extension is not part of the BASIC language; the file contents must be readable text. |
Numbered line | A line beginning with a decimal line number is stored in the program. |
The browser File API reads the selected file locally; the program is not uploaded to a remote server. Line endings are normalized and numbered lines are inserted into memory. On iPadOS, custom .BAS extensions may be greyed out if the file input restricts recognized types; an unrestricted file picker or a temporary .TXT filename avoids that problem.
The original runnable examples are retained below.
10 PRINT "LOADED FROM LOCAL PC"
20 ENDSelect SAVE ASCII BASIC to download the current program as a plain-text .BAS file. Lines are saved in ascending order with their line numbers. The file can be edited with Notepad, Notepad++, VS Code, or another text editor, then loaded back into the emulator. Saving does not include current variable values, screen contents, or execution state.
Downloads the current numbered listing as a portable plain-text BASIC file.
Select SAVE ASCII BASICThe emulator sorts program lines numerically, joins them with text line endings, and asks the browser to download the result. Only source code is saved. Variables, arrays, screen output, current DATA position, and execution state are not included.
The original runnable examples are retained below.
The portable program format uses ordinary printable characters and line endings. Avoid rich-text editors that may insert formatting or typographic quotation marks. Use straight double quotes around BASIC strings. A line without a leading number is not stored as part of a loaded program. Keep a backup before making large edits.
Defines the portable, human-readable format used for loading and saving emulator programs.
10 PRINT "HELLO"20 END| Element | Description |
|---|---|
Line number | Decimal number at the beginning of each stored program line. |
Statement text | One or more BASIC statements following the line number. |
Encoding | UTF-8 or ordinary ASCII-compatible plain text. |
The format is source text, not the tokenized binary representation used by some historical BASIC systems. Each physical text line should contain one numbered BASIC line. Colons may combine multiple statements within that line.
The original runnable examples are retained below.
PRINT displays strings, numeric expressions, variables, array elements, and function results. A bare PRINT outputs a blank line. Items can be separated by semicolons or commas. Numbers are formatted without unnecessary trailing zeros. Strings are printed exactly as evaluated.
Writes text, numbers, variables, array elements, or expression results to the emulator display.
PRINT "TEXT"PRINT expressionPRINT item1;item2PRINT item1,item2PRINT| Element | Description |
|---|---|
item | A string expression, numeric expression, variable, array element, or supported function. |
; | Joins output without ordinary tab-zone spacing; a trailing semicolon suppresses the newline. |
, | Advances output toward the next print zone. |
bare PRINT | Produces a blank line or terminates a line previously held open. |
PRINT evaluates each item from left to right and converts numeric results to readable text. String literals appear without quotation marks. Array references and functions are evaluated exactly as they would be in assignments or conditions.
The original runnable examples are retained below.
PRINT "TOTAL=";A
PRINT X(I)
PRINTA semicolon joins output without automatically advancing to the next display line. It is useful for constructing tables, progress indicators, and rows of symbols. In this emulator, PRINT statements ending with a semicolon preserve the current output line for the next PRINT.
Controls horizontal output by placing values directly next to one another and optionally suppressing the newline.
PRINT "A";"B"PRINT I;" ";PRINTSemicolons are useful for rows, prompts, progress displays, and character graphics. A trailing semicolon leaves the current output line open. A later bare PRINT advances to the next line.
The original runnable examples are retained below.
10 FOR I=1 TO 10
20 PRINT I;" ";
30 NEXT I
40 PRINTA comma advances output toward the next tab zone. This resembles classic BASIC column formatting and is useful for aligned reports. Exact spacing depends on the current column and the emulator tab-zone width.
Formats output in fixed-width print zones similar to classic BASIC report columns.
PRINT "NAME","SCORE"PRINT A,B,CThe emulator advances to the next 16-column zone based on the current output position. Commas are convenient for rough tables but do not guarantee alignment for values longer than a zone.
The original runnable examples are retained below.
PRINT "NAME","SCORE"
PRINT "RICH",100TAB(N) inserts spaces until the output reaches column N. If the current column has already passed N, no reverse movement occurs. TAB is intended for formatted reports and headings rather than random-access screen placement.
Inserts spaces until output reaches a requested character column.
PRINT TAB(N);"TEXT"| Element | Description |
|---|---|
N | Numeric expression representing the target column. |
TAB only moves forward. If output has already passed the requested column, no backward cursor movement occurs. TAB is evaluated during PRINT processing and is most useful for headings and reports.
The original runnable examples are retained below.
PRINT TAB(20);"CENTER AREA"PRINT @ places text at a simulated screen-memory position on a 64-column by 16-row display. Position zero is the upper-left character. The row is position divided by 64; the column is the remainder. Positions wrap within the 1024-character screen area. This feature is well suited to menus, scoreboards, and character animation.
Writes text at a specific location in the simulated 64-by-16 character screen memory.
PRINT @ position,"TEXT"PRINT @ expression;value| Element | Description |
|---|---|
position | Numeric expression from 0 through 1023; values are wrapped into the screen area. |
row | Computed as INT(position/64). |
column | Computed as position MOD 64. |
PRINT @ allows menus, scoreboards, and animation without producing a scrolling line for every update. Text overwrites existing characters beginning at the selected position.
The original runnable examples are retained below.
10 CLS
20 PRINT @ 0,"TOP LEFT"
30 PRINT @ 128,"ROW 2"INPUT pauses the program, displays a question prompt, and waits for a value. INPUT A stores a numeric value; INPUT A$ stores text. Press Enter to submit. BREAK, Esc, or Ctrl+C cancels a waiting INPUT and interrupts the program. Numeric input that cannot be parsed becomes zero in this emulator.
Pauses a program and obtains a numeric or string value from the user.
INPUT AINPUT A$| Element | Description |
|---|---|
A | Single-letter numeric variable. |
A$ | Single-letter string variable. |
INPUT displays a question prompt and waits for Enter. Numeric input is converted with browser number parsing; invalid numeric text becomes zero in this implementation. BREAK, Esc, or Ctrl+C cancels the wait and interrupts the program.
The original runnable examples are retained below.
10 INPUT A
20 PRINT "YOU ENTERED ";ALET assigns a value to a variable or array element. LET is optional. Numeric expressions are stored in numeric variables; string expressions are stored in names ending with a dollar sign. Array elements must have been dimensioned before assignment.
Stores the result of an expression in a scalar variable or array element.
LET A=expressionA=expressionA$="text"X(I)=expressionN$(I)=string-expression| Element | Description |
|---|---|
LET | Optional keyword retained for traditional BASIC readability. |
destination | Numeric variable, string variable, numeric array element, or string array element. |
expression | Value evaluated before storage. |
The destination type determines whether the expression is interpreted as numeric or string. Array elements require a preceding DIM declaration. String assignments are limited to the emulator's configured maximum length.
The original runnable examples are retained below.
LET A=10
B=A*2
LET X(I)=B
N$="TRS-80"REM marks a comment. The interpreter ignores the remainder of that statement. Comments should explain purpose, assumptions, data formats, and non-obvious calculations. Clear comments are especially valuable in programs that use many GOTO targets.
Adds explanatory text to a program without executing it.
REM comment text100 REM INITIALIZE ARRAYSThe interpreter ignores the remainder of the REM statement. Comments can identify sections, explain formulas, describe variable use, or record compatibility changes made to an imported historical listing.
The original runnable examples are retained below.
10 REM INITIALIZE SCREEN
20 CLSEND terminates program execution normally. It is optional at the physical end of a program, but including it makes the intended stopping point clear and prevents accidental entry into subroutines placed later in the listing.
Terminates program execution normally.
ENDEND prevents execution from continuing into later lines, especially subroutines placed after the main program. Reaching the physical end of the listing also stops execution, but an explicit END documents intent.
The original runnable examples are retained below.
100 END
500 REM SUBROUTINES MAY FOLLOWA colon separates multiple statements on one numbered line. Colons inside quoted strings are not separators. Compact lines save listing space, but excessive chaining makes programs harder to debug. GOTO and loop behavior operate on the flattened statement sequence.
Places more than one BASIC statement on the same numbered line.
10 A=1:B=2:PRINT A+BThe interpreter divides a line at top-level colons while preserving colons inside quoted strings. Statements then execute in their written order. Branches operate on the flattened statement sequence.
The original runnable examples are retained below.
10 A=1: B=2: PRINT A+BGOTO transfers execution to the first statement on the specified line. The target line must exist. Unstructured jumps are historically common in BASIC, but reserve line-number ranges for major sections and document important targets.
Transfers execution unconditionally to a numbered program line.
GOTO line-number| Element | Description |
|---|---|
line-number | Existing numbered line that becomes the next execution point. |
GOTO is useful for main loops, retries, state transitions, and exits from conditional sections. The emulator jumps to the first statement on the target line.
The original runnable examples are retained below.
10 PRINT "AGAIN"
20 GOTO 10IF evaluates a numeric condition. Zero is false; any nonzero value is true. In this emulator, THEN is followed by a line number. When true, execution jumps to that line. When false, execution continues with the next statement.
Tests a condition and branches to a line number when the condition is true.
IF condition THEN line-number| Element | Description |
|---|---|
condition | Numeric expression; zero is false and any nonzero value is true. |
line-number | Target executed only when the condition is true. |
Comparisons return numeric 1 or 0 and can be combined with AND, OR, and NOT. When the condition is false, execution continues with the next statement.
The original runnable examples are retained below.
10 IF A>5 THEN 100
20 PRINT "A IS 5 OR LESS"Comparisons return 1 for true and 0 for false. Supported operators are =, <>, <, <=, >, and >=. Comparisons may be combined with AND, OR, and NOT. Parentheses make intent clear and reduce precedence mistakes.
Compares numeric values and returns 1 for true or 0 for false.
A=BA<>BAA<=BA>BA>=BParameters and Elements
Element Description =Equal <>Not equal <Less than <=Less than or equal >Greater than >=Greater than or equal
Detailed Description
Comparison results are ordinary numeric values. They may be printed, assigned, or used as IF conditions. Floating-point calculations can contain tiny rounding differences, so exact equality after complex decimal arithmetic should be used carefully.
Programming Guidance
- Use a tolerance test such as ABS(A-B)<0.0001 for approximate decimal equality.
- Parenthesize comparisons before combining them with AND or OR.
Related Entries
Examples
The original runnable examples are retained below.
PRINT 5=5
PRINT 5<>4
PRINT (A>=1) AND (A<=10)GOSUB transfers control to a subroutine and stores the return point. RETURN resumes after the calling GOSUB. Subroutines are useful for repeated printing, calculations, input validation, and screen setup. RETURN without a matching GOSUB causes an error.
Calls a reusable subroutine and later resumes execution after the call.
GOSUB line-numberRETURN| Element | Description |
|---|---|
line-number | First line of the subroutine. |
RETURN | Uses the most recently saved return point. |
GOSUB pushes the current execution position onto a stack and branches. RETURN pops that position and continues after the GOSUB. Nested subroutine calls are permitted as stack space allows.
The original runnable examples are retained below.
10 GOSUB 100
20 END
100 PRINT "SUBROUTINE"
110 RETURNFOR initializes a single-letter numeric variable, records an ending value and step, and begins a loop. NEXT increments the variable and either repeats or exits. The default step is 1. Negative steps count downward. The NEXT variable must match the active FOR frame.
Repeats a block of statements while advancing a numeric control variable.
FOR I=start TO finishFOR I=start TO finish STEP incrementNEXT I| Element | Description |
|---|---|
I | Single-letter numeric loop variable. |
start | Initial numeric value. |
finish | Inclusive ending value. |
increment | Amount added each repetition; defaults to 1. |
FOR assigns the start value and records the loop frame. NEXT increments the variable and repeats when it has not passed the ending value. Positive and negative steps are supported.
The original runnable examples are retained below.
10 FOR I=1 TO 10
20 PRINT I
30 NEXT ISTEP changes the increment used by FOR. Fractional and negative steps are accepted. A positive step continues while the variable is less than or equal to the ending value. A negative step continues while it is greater than or equal to the ending value.
Specifies the amount and direction by which a FOR loop variable changes.
FOR I=1 TO 10 STEP 2FOR I=10 TO 1 STEP -1Positive STEP values count upward; negative values count downward. The finish value remains inclusive. Fractional steps are accepted because variables use floating-point numbers.
The original runnable examples are retained below.
FOR I=10 TO 0 STEP -2
PRINT I
NEXT ILoops may be nested. Each NEXT must close the most recent matching FOR. Nested loops are useful for tables, grids, array initialization, and cellular automata. Keep loop variables distinct and indent the source in an external editor when possible.
Uses one FOR/NEXT loop inside another to process rows, columns, combinations, or multidimensional arrays.
FOR R=0 TO 5 FOR C=0 TO 5 A(R,C)=R*C NEXT CNEXT RThe innermost active loop completes for each iteration of the outer loop. The emulator tracks loop frames in stack order, so NEXT must match the active structure.
The original runnable examples are retained below.
10 FOR R=1 TO 5
20 FOR C=1 TO 10
30 PRINT "*";
40 NEXT C
50 PRINT
60 NEXT RPAUSE milliseconds delays execution for approximately the requested number of milliseconds. Unlike a busy-wait BASIC loop, PAUSE yields to the browser and remains interruptible. Use PAUSE for animation pacing and demonstrations. Browser timing is not suitable for precision measurement.
Delays program execution for approximately a specified number of milliseconds while keeping the browser responsive.
PAUSE milliseconds| Element | Description |
|---|---|
milliseconds | Numeric expression converted to a nonnegative integer delay. |
PAUSE uses asynchronous browser timing rather than a busy loop. The interpreter continues checking for BREAK during the delay, making it suitable for animation and demonstrations.
The original runnable examples are retained below.
10 PRINT "TICK"
20 PAUSE 500
30 GOTO 10DATA stores constant values inside the program. Items are separated by commas and may be numeric or quoted strings. DATA statements do nothing when reached during normal execution; they are scanned before RUN to construct the data pool.
Stores constant numeric and string values inside the program for sequential retrieval by READ.
DATA 10,20,30DATA "RED","GREEN","BLUE"DATA statements are scanned before RUN and placed into a shared data pool. Reaching a DATA line during ordinary execution performs no visible action.
The original runnable examples are retained below.
10 DATA 10,20,30,"DONE"READ obtains the next item from the DATA pool and places it into a numeric or string variable. READ past the final item causes an error. This emulator currently documents READ into scalar variables; use assignment afterward to place values into arrays.
Retrieves the next value from the program's DATA pool.
READ AREAD A$| Element | Description |
|---|---|
A | Numeric scalar destination. |
A$ | String scalar destination. |
Each READ advances the shared DATA pointer. Values are converted to the destination type. To place a value into an array, READ it into a scalar and then assign the scalar to the array element.
The original runnable examples are retained below.
10 DATA 5,10,15
20 READ A
30 PRINT ARESTORE resets the DATA pointer to the first DATA item. It permits the same data list to be read again. This implementation restores to the beginning rather than to a particular line number.
Moves the DATA pointer back to the first DATA item.
RESTOREAfter RESTORE, the next READ returns the first data value again. This implementation does not document RESTORE with a line-number argument.
The original runnable examples are retained below.
10 DATA 1,2
20 READ A
30 RESTORE
40 READ BNumeric variable names are the single letters A through Z. Values use JavaScript floating-point numbers internally. Integer-looking results are displayed as integers; other results are rounded for readable output. Programs that require exact decimal financial arithmetic should account for binary floating-point behavior.
Stores numeric values used in calculations, loops, comparisons, and array subscripts.
A=10R=PI/2PRINT AScalar numeric names are A through Z. Values are JavaScript double-precision floating-point numbers internally. This offers a large range but includes the usual binary floating-point rounding behavior.
The original runnable examples are retained below.
String variable names are A$ through Z$. Strings can be assigned from literals, string variables, string functions, or concatenations. Stored strings are limited to 255 characters by assignment in this emulator.
Stores text values for messages, names, menus, and input.
A$="MODEL 4"PRINT A$Scalar string names are A$ through Z$. String expressions can combine literals, variables, and supported string functions. Assignment truncates strings to the emulator's configured maximum length.
The original runnable examples are retained below.
A$="MODEL "+"4"
PRINT A$DIM creates numeric or string arrays. Array names use a single letter, optionally followed by $. Dimensions are inclusive, so DIM X(68) permits subscripts 0 through 68. Arrays are reset when RUN begins or CLEAR is issued. DIM may contain expressions such as DIM X(M) if M has already been assigned.
Declares numeric or string arrays and establishes their valid subscript ranges.
DIM X(68)DIM X (M)DIM A(10,10)DIM N$(20)| Element | Description |
|---|---|
array name | Single letter, optionally followed by $ for strings. |
dimension | Inclusive upper bound; DIM X(68) creates elements X(0) through X(68). |
multiple dimensions | Comma-separated upper bounds for tables or grids. |
DIM must execute before an array is read or written. Dimension expressions are evaluated at runtime, so a variable such as M may determine the size if it has already been assigned. New elements initially read as zero or an empty string.
The original runnable examples are retained below.
5 LET M=68
10 DIM X(M)
20 DIM Y(M)A one-dimensional array is a numbered list of elements. Use it for scores, samples, character states, lookup tables, and histories. Every element initially contains zero, or an empty string for string arrays. Subscripts are truncated to integers.
Stores an indexed sequence of related values under one array name.
DIM X(100)X(I)=valuePRINT X(I)One-dimensional arrays model lists, time series, scores, counters, and cellular states. The lower bound is zero and the declared number is the inclusive upper bound.
The original runnable examples are retained below.
10 DIM X(10)
20 FOR I=0 TO 10
30 X(I)=I*I
40 NEXT IMultiple dimensions create tables or higher-dimensional grids. DIM A(10,10) permits row and column subscripts from 0 through 10. The number of subscripts used later must match the declaration. Values are stored sparsely in the emulator, so untouched elements consume minimal entry storage.
Stores table, matrix, grid, or higher-dimensional data addressed by more than one subscript.
DIM A(10,10)A(R,C)=valuePRINT A(R,C)Each dimension has an inclusive zero-based range. The number of subscripts in every later reference must equal the number declared by DIM. The emulator stores values using a sparse key representation, so untouched elements remain at their default value.
The original runnable examples are retained below.
10 DIM A(5,5)
20 A(2,3)=99
30 PRINT A(2,3)A string array is dimensioned with a dollar-sign name. Each unassigned element reads as an empty string. String arrays are useful for menus, names, messages, and text maps.
Stores multiple text values that can be selected by a numeric subscript.
DIM N$(20)N$(0)="FIRST"PRINT N$(I)String arrays are useful for menu labels, names, map rows, messages, and lookup tables. Unassigned elements return an empty string.
The original runnable examples are retained below.
10 DIM N$(3)
20 N$(0)="ZERO"
30 PRINT N$(0)Subscripts may be constants, variables, arithmetic expressions, or function results. They are evaluated when the element is read or written and truncated to integers. Negative subscripts and subscripts greater than the declared upper bound cause SUBSCRIPT OUT OF RANGE.
Selects a particular element from an array.
X(5)X(I)X(I+1)A(R,C)| Element | Description |
|---|---|
subscript expression | Numeric expression evaluated and truncated to an integer. |
valid range | Zero through the corresponding declared upper bound. |
Subscripts can contain variables, arithmetic, and supported numeric functions. They are checked every time an element is read or written.
The original runnable examples are retained below.
X(I+1)=X(I)*2
PRINT A(R,C)ARRAY NOT DIMENSIONED means an element was used before DIM. WRONG NUMBER OF SUBSCRIPTS means the reference does not match the declared rank. SUBSCRIPT OUT OF RANGE means an index is below zero or above its upper bound. NEGATIVE ARRAY DIMENSION and BAD DIM STATEMENT report invalid declarations.
Explains runtime failures caused by invalid declarations or references.
ARRAY NOT DIMENSIONEDWRONG NUMBER OF SUBSCRIPTSSUBSCRIPT OUT OF RANGEBAD DIM STATEMENTArray checking protects the program from silently reading or writing an unintended element. The error usually identifies a missing DIM, an incorrect loop limit, a neighbor calculation at an edge, or a mismatch between one- and two-dimensional use.
The original runnable examples are retained below.
The arithmetic operators are +, -, *, /, ^, MOD, and postfix factorial !. Parentheses control evaluation order. Division or modulus by zero causes an error. Exponentiation uses JavaScript Math.pow behavior.
Performs numeric calculations.
A+BA-BA*BA/BA^BA MOD BN!| Element | Description |
|---|---|
+ | Addition |
- | Subtraction or unary negation |
* | Multiplication |
/ | Division |
^ | Exponentiation |
MOD | Remainder |
! | Postfix factorial |
Arithmetic expressions may contain constants, variables, array elements, functions, and parentheses. Normal precedence applies, but parentheses are strongly recommended in mixed expressions.
The original runnable examples are retained below.
PRINT (2+3)*4
PRINT 2^8
PRINT 10 MOD 3
PRINT 5!AND is true when both operands are nonzero. OR is true when either operand is nonzero. NOT converts zero to 1 and nonzero to 0. Logical results are numeric and can be printed, assigned, or used in IF.
Combines or reverses truth values represented numerically.
condition1 AND condition2condition1 OR condition2NOT condition| Element | Description |
|---|---|
AND | Returns 1 only when both operands are nonzero. |
OR | Returns 1 when either operand is nonzero. |
NOT | Returns 1 for zero and 0 for nonzero. |
Logical operations are most commonly used inside IF, but their numeric results can also be assigned or printed.
The original runnable examples are retained below.
PRINT (A>0) AND (A<10)
PRINT NOT 0ABS returns magnitude. INT rounds downward. FIX truncates toward zero. ROUND returns the nearest integer using JavaScript rounding behavior. SGN returns -1, 0, or 1. These functions are helpful for numeric formatting, loop bounds, and simulations.
Provides common value-normalization and integer-conversion operations.
ABS(X)INT(X)FIX(X)ROUND(X)SGN(X)| Element | Description |
|---|---|
ABS | Magnitude without sign. |
INT | Greatest integer less than or equal to X. |
FIX | Truncates toward zero. |
ROUND | Rounds to the nearest integer using browser behavior. |
SGN | Returns -1, 0, or 1. |
INT and FIX differ for negative values: INT(-3.1) is -4, while FIX(-3.1) is -3. SGN is useful for direction and comparison logic.
The original runnable examples are retained below.
PRINT ABS(-25)
PRINT INT(-3.1)
PRINT FIX(-3.9)
PRINT SGN(-8)SQR returns the square root and rejects negative input. EXP raises e to a power. LOG returns the natural logarithm. Very large or invalid mathematical results follow browser numeric behavior where not explicitly trapped.
Calculates square roots, exponential values, and natural logarithms.
SQR(X)EXP(X)LOG(X)| Element | Description |
|---|---|
SQR(X) | Square root; X must be nonnegative. |
EXP(X) | e raised to X. |
LOG(X) | Natural logarithm; mathematically requires X greater than zero. |
These functions use the browser's standard mathematical library. They are useful in geometry, growth and decay, statistics, and scientific calculations.
The original runnable examples are retained below.
PRINT SQR(144)
PRINT EXP(1)
PRINT LOG(E)Trigonometric functions use radians. Convert degrees to radians by multiplying by PI/180. TAN becomes very large near odd multiples of PI/2 because of floating-point approximation.
Evaluates the principal trigonometric functions using radians.
SIN(X)COS(X)TAN(X)| Element | Description |
|---|---|
X | Angle measured in radians. |
Convert degrees with radians=degrees*PI/180. These functions support geometry, oscillation, circular movement, and waveform calculations.
The original runnable examples are retained below.
R=45*PI/180
PRINT SIN(R),COS(R),TAN(R)Inverse trigonometric functions return radians. ASN and ACS expect values in the mathematical domain -1 through 1. ATN accepts any finite numeric value.
Returns inverse trigonometric angles in radians.
ASN(X)ACS(X)ATN(X)| Element | Description |
|---|---|
ASN | Arcsine; X normally lies from -1 to 1. |
ACS | Arccosine; X normally lies from -1 to 1. |
ATN | Arctangent; accepts any finite X. |
Multiply the returned radians by 180/PI to obtain degrees. Inverse functions are useful when deriving an angle from a ratio or coordinate relationship.
The original runnable examples are retained below.
PRINT ATN(1)*180/PIMIN and MAX accept multiple comma-separated numeric expressions. They return the smallest or largest result. Use them to clamp ranges, analyze data, or compare candidates.
Selects the smallest or largest value from a list of numeric expressions.
MIN(A,B,...)MAX(A,B,...)Every argument is evaluated before the result is selected. These functions are useful for limits, range analysis, clipping, and comparisons among several candidates.
The original runnable examples are retained below.
PRINT MIN(10,20,5)
PRINT MAX(10,20,5)The postfix ! operator and FACT(X) calculate factorial after truncating X to an integer. Negative values are rejected. Values above 170 are rejected because they exceed useful finite JavaScript number range.
Calculates the product of all positive integers from 1 through a nonnegative integer.
N!FACT(N)The argument is truncated to an integer. Both syntaxes use the same implementation. Factorials are used in combinations, permutations, probability, and series expansions.
The original runnable examples are retained below.
PRINT 6!
PRINT FACT(6)RND or RND() returns a pseudo-random value from zero up to but not including one. RND(X) returns that value multiplied by X. RANDINT(A,B) returns an integer from A through B inclusive. Random sequences are supplied by the browser and are not cryptographically secure.
Generates pseudo-random values for games, simulations, sampling, and randomized initialization.
RNDRND()RND(X)RANDINT(A,B)| Element | Description |
|---|---|
RND / RND() | Value from 0 inclusive to 1 exclusive. |
RND(X) | Random fraction multiplied by X. |
RANDINT(A,B) | Integer from A through B inclusive. |
The emulator uses the browser's pseudo-random generator. RND(1) therefore behaves like RND()*1, which is useful for compatibility with listings that include a dummy argument.
The original runnable examples are retained below.
R=RND(1)*10
D=RANDINT(1,6)PI and E provide common mathematical constants. TRUE equals 1 and FALSE equals 0. These names can be used wherever a numeric expression is accepted.
Provides named numeric constants.
PIETRUEFALSE| Element | Description |
|---|---|
PI | Approximately 3.141592653589793. |
E | Approximately 2.718281828459045. |
TRUE | Numeric 1. |
FALSE | Numeric 0. |
Named constants make mathematical and logical expressions clearer than embedding approximate decimal values.
The original runnable examples are retained below.
LEN returns string length. ASC returns the character code of the first character, or zero for an empty string. VAL converts the beginning of a numeric-looking string to a number; invalid text becomes zero.
Inspects or converts string data.
LEN(A$)ASC(A$)VAL(A$)| Element | Description |
|---|---|
LEN | Number of characters. |
ASC | Character code of the first character; zero for an empty string. |
VAL | Numeric conversion of text; invalid text becomes zero. |
These functions help validate input, decode characters, and convert text fields into numbers.
The original runnable examples are retained below.
PRINT LEN("MODEL 4")
PRINT ASC("A")
PRINT VAL("123")+7CHR$(N) returns the character whose 8-bit code is N. STR$(N) converts a numeric value to text. These functions bridge numeric and string processing.
Converts between character codes, numbers, and strings.
CHR$(N)STR$(N)| Element | Description |
|---|---|
CHR$(N) | Character corresponding to the low 8 bits of N. |
STR$(N) | Text representation of a numeric expression. |
CHR$ is useful for generated characters and simple text protocols. STR$ allows numeric results to participate in string concatenation.
The original runnable examples are retained below.
PRINT CHR$(65)
A$=STR$(123)LEFT$ returns characters from the beginning, RIGHT$ from the end, and MID$ from a one-based starting position. MID$ may include an optional length. Out-of-range slicing follows safe browser string behavior and returns available text.
Extracts a substring from the beginning, end, or middle of a string.
LEFT$(A$,N)RIGHT$(A$,N)MID$(A$,START)MID$(A$,START,LENGTH)| Element | Description |
|---|---|
A$ | Source string expression. |
N / LENGTH | Number of characters. |
START | One-based starting position. |
LEFT$ and RIGHT$ select from the ends. MID$ subtracts one from START to map traditional BASIC indexing to browser string indexing. Requests beyond available text return the portion that exists.
The original runnable examples are retained below.
A$="RADIO SHACK"
PRINT LEFT$(A$,5)
PRINT RIGHT$(A$,5)
PRINT MID$(A$,7,5)UPPER$ and LOWER$ change letter case. TRIM$ removes leading and trailing whitespace. They are emulator conveniences useful when comparing input and preparing reports.
Normalizes the case and surrounding whitespace of strings.
UPPER$(A$)LOWER$(A$)TRIM$(A$)These emulator extensions simplify menu input and text processing. UPPER$ and LOWER$ change letter case; TRIM$ removes whitespace at both ends.
The original runnable examples are retained below.
INKEY$ returns the last ordinary key pressed and then clears the stored key. It does not wait. Programs can poll INKEY$ in a loop for simple interactive control, but should include PAUSE or other pacing to avoid excessive CPU use.
Returns the most recently pressed ordinary key without pausing the program.
A$=INKEY$INKEY$ is nonblocking. After it returns the stored key, the stored value is cleared, so a later call returns an empty string until another key is pressed.
The original runnable examples are retained below.
10 A$=INKEY$
20 IF A$="" THEN 10
30 PRINT A$Use parentheses whenever an expression mixes arithmetic, comparison, and logical operations. The evaluator handles unary signs, exponentiation, multiplication and division, addition and subtraction, comparisons, NOT, AND, and OR. Parentheses are the clearest way to communicate intended order.
Determines the order in which parts of a mixed expression are evaluated.
(parentheses)unary sign / NOT^ and !* / MOD+-comparisonsANDORThe parser implements precedence rules, but complex expressions are easier to read and safer to port when parentheses explicitly state the desired order.
The original runnable examples are retained below.
The simulated character display is modeled as 64 columns by 16 rows for PRINT @ addressing. Normal terminal output can scroll beyond those dimensions. PRINT @ updates the screen-memory region and keeps it visible near the top.
Text characters can act as graphics. Asterisks, spaces, plus signs, slashes, and letters can form charts, mazes, vehicles, or cellular automata. PRINT @ is useful for placing individual objects, while semicolon PRINT is useful for building rows.
Animation usually follows four steps: erase or clear the previous image, update state variables, draw the new image, and PAUSE. Use BREAK to stop an animation. Avoid extremely short GOTO loops without pacing, because they can flood the terminal with output.
Temporary PRINT statements reveal variable values, branch choices, and array contents. Include labels so the output is meaningful. Remove or comment debug lines after the program works.
PRINT "I=";I;" C=";C;" X(I)=";X(I)Create a line-number map before writing a large program. Typical ranges might reserve 10-99 for initialization, 100-499 for the main loop, 500-799 for subroutines, and 800-999 for error handling. LIST verifies that every target exists.
Check DIM upper bounds, loop start and end values, and every calculated subscript. Remember that DIM X(68) includes both X(0) and X(68). A loop from 0 TO M is therefore valid when the array was dimensioned with M.
Every intentional loop should have an exit condition or be designed to run until BREAK. During development, add a counter or PAUSE. The new interrupt system lets you recover from GOTO loops, long FOR loops, pauses, and waiting input without reloading the page.
Begin with initialization, then enter a main loop, then place subroutines after END. Use comments and consistent line-number ranges. Keep calculations in small sections and avoid changing a FOR control variable inside its loop unless the effect is deliberate.
The interpreter periodically yields to the browser so the screen remains responsive and BREAK can be detected. A JavaScript implementation does not execute at the same speed as a physical 1980s computer. Timing loops therefore should not be used as clocks; use PAUSE for visible pacing.
This is a TinyBASIC-style web interpreter inspired by the TRS-80 Model 4. It is not a byte-for-byte Microsoft BASIC, Level II BASIC, Model III BASIC, or TRSDOS BASIC clone. Programs that depend on PEEK, POKE, machine language, disk channels, graphics hardware, SOUND syntax, ON GOTO, or other undocumented features may require adaptation.
?SN ERROR indicates that a statement did not match the implemented grammar. Check spelling, required keywords, parentheses, commas, line numbers, and quotation marks. Unsupported historical BASIC statements also produce this error.
Important runtime messages include DIVISION BY ZERO, MOD BY ZERO, NO SUCH LINE, NEXT WITHOUT FOR, NEXT VARIABLE MISMATCH, RETURN WITHOUT GOSUB, READ PAST END OF DATA, NEGATIVE FACTORIAL, FACTORIAL TOO LARGE, ARRAY NOT DIMENSIONED, WRONG NUMBER OF SUBSCRIPTS, and SUBSCRIPT OUT OF RANGE.
This introductory program demonstrates FOR, NEXT, semicolon output, and a final blank PRINT.
10 CLS
20 FOR I=1 TO 20
30 PRINT I;" ";
40 NEXT I
50 PRINT
60 ENDRANDINT produces an integer from one through six. Re-run the program for another roll.
10 CLS
20 PRINT "DICE ROLL: ";RANDINT(1,6)
30 ENDThis simple game selects a target and branches according to the player input.
10 A=RANDINT(1,10)
20 PRINT "GUESS 1 TO 10"
30 INPUT G
40 IF G=A THEN 100
50 PRINT "TRY AGAIN"
60 GOTO 30
100 PRINT "CORRECT"
110 ENDNested loops and formatted PRINT create a compact multiplication table.
10 FOR R=1 TO 10
20 FOR C=1 TO 10
30 PRINT R*C,
40 NEXT C
50 PRINT
60 NEXT RThe program counts exact divisors. It uses MOD and a loop.
10 INPUT N
20 C=0
30 FOR I=1 TO N
40 IF N MOD I=0 THEN 60
50 GOTO 70
60 C=C+1
70 NEXT I
80 IF C=2 THEN 110
90 PRINT "NOT PRIME"
100 END
110 PRINT "PRIME"This program dimension an array, fills it, and prints it.
10 DIM X(20)
20 FOR I=0 TO 20
30 X(I)=I*I
40 NEXT I
50 FOR I=0 TO 20
60 PRINT I;" ";X(I)
70 NEXT IA two-dimensional array stores products by row and column.
10 DIM A(5,5)
20 FOR R=0 TO 5
30 FOR C=0 TO 5
40 A(R,C)=R*C
50 NEXT C
60 NEXT R
70 PRINT A(4,5)A string array stores labels that can be printed in a loop.
10 DIM M$(3)
20 M$(0)="RUN"
30 M$(1)="LIST"
40 M$(2)="SAVE"
50 M$(3)="BREAK"
60 FOR I=0 TO 3
70 PRINT I;" ";M$(I)
80 NEXT IPRINT @ and PAUSE create a simple moving character. Press BREAK to stop or allow it to finish.
10 CLS
20 FOR P=0 TO 63
30 PRINT @ P,"*"
40 PAUSE 50
50 PRINT @ P," "
60 NEXT PThe array counts 100 simulated die rolls and prints totals.
10 DIM C(6)
20 FOR I=1 TO 100
30 D=RANDINT(1,6)
40 C(D)=C(D)+1
50 NEXT I
60 FOR D=1 TO 6
70 PRINT D;" ";C(D)
80 NEXT DDATA, READ, and RESTORE provide an embedded table.
10 DATA 10,20,30,40
20 FOR I=1 TO 4
30 READ A
40 PRINT A
50 NEXT I
60 RESTOREA reusable heading routine is called twice.
10 GOSUB 100
20 PRINT "FIRST SECTION"
30 GOSUB 100
40 PRINT "SECOND SECTION"
50 END
100 PRINT "----------------"
110 RETURNThis cellular-automaton program demonstrates DIM, two arrays, random initialization, nested loops, array references in conditions, array assignments, GOTO, and repeated generations. It runs continuously because line 350 returns to initialization; use BREAK PROGRAM, the virtual BREAK key, Esc, or Ctrl+C to stop it.
5 LET M = 68
10 DIM X (M)
20 DIM Y (M)
30 FOR I = 0 TO M
40 LET R = RND(1) * 10
50 IF R > 5 THEN 80
60 LET X(I) = 1
70 GOTO 90
80 LET X(I) = 0
90 NEXT I
100 FOR I = 2 TO M-2
110 IF X(I) = 1 THEN 140
120 PRINT " ";
130 GOTO 150
140 PRINT "*";
150 NEXT I
160 PRINT
170 GOTO 200
200 FOR T = 0 TO 25
210 FOR I = 2 TO M-2
220 GOTO 500
230 NEXT I
260 FOR I = 0 TO M
270 LET X(I) = Y(I)
280 IF X(I) = 0 THEN 310
290 PRINT "*";
300 GOTO 320
310 PRINT " ";
320 NEXT I
330 PRINT
340 NEXT T
350 GOTO 30
500 LET C = 0
510 FOR Z = (I-2) TO (I+2)
520 IF Z = I THEN 550
530 IF X(Z) = 0 THEN 550
540 LET C = C + 1
550 NEXT Z
560 IF X(I) = 0 THEN 800
700 LET Y(I) = 0
710 IF C = 2 THEN 750
720 IF C = 4 THEN 750
730 GOTO 230
750 LET Y(I) = 1
760 GOTO 230
800 LET Y(I) = 0
810 IF C = 2 THEN 850
820 IF C = 3 THEN 850
830 GOTO 230
850 LET Y(I) = 1
860 GOTO 230Old magazine and manual listings may use syntax not implemented here. First preserve the original file, then replace unsupported commands one at a time. PEEK/POKE graphics can often be rewritten with PRINT @. Timing loops can become PAUSE. Disk file operations can be replaced by browser ASCII LOAD and SAVE for whole-program storage.
Save frequently under versioned filenames such as LIFE01.BAS, LIFE02.BAS, and LIFE03.BAS. Plain ASCII files are small and easy to archive. Keep a known-working copy before changing loops, branch targets, or array dimensions.
Set the document to plain text and use a monospaced font. Keep line endings consistent. BASIC keywords may be uppercase for a period appearance, although the emulator matches keywords case-insensitively. Do not let smart-quote substitution change straight quotation marks.
Tap the green screen to focus the hidden input control. The on-screen keyboard can enter common keys and function shortcuts. Local file loading and downloading depend on browser file-picker behavior. For long programs, editing on a desktop text editor and transferring the .BAS file is usually more comfortable.
F1 types LIST, F2 RUN, F3 NEW, F4 CLS, F5 PRINT, F6 GOTO, F7 INPUT, and F8 HELP on the on-screen keyboard. ENTER submits. BREAK interrupts execution. Esc interrupts a running program or clears a non-running input line. Ctrl+C interrupts execution. The physical keyboard adds Up/Down command-history recall; Left/Right cursor movement; Home/End movement to the beginning or end of the current line; Backspace to remove the character before the cursor; and Delete to remove the character at the cursor. Recalled commands remain fully editable before ENTER is pressed.
Core commands include RUN, LIST, EDIT n, NEW, CLEAR, CLS, HELP, MEM, DIR/FILES, LOAD, SAVE, KILL/DELETE, RENAME, BASIC, and SYSTEM. Core statements include PRINT, INPUT, LET, DIM, REM, END, GOTO, IF...THEN, GOSUB, RETURN, FOR, NEXT, DATA, READ, RESTORE, and PAUSE. Browser controls add ASCII LOAD, ASCII SAVE, virtual-disk import/export, RESET / BOOT, and BREAK PROGRAM.
Numeric functions: ABS, ASN, ACS, ATN, COS, EXP, FACT, FIX, INT, LOG, MAX, MIN, RANDINT, RND, ROUND, SGN, SIN, SQR, and TAN. String-related functions: LEN, ASC, VAL, CHR$, STR$, LEFT$, RIGHT$, MID$, UPPER$, LOWER$, and TRIM$. INKEY$ reports the last key.
ABS, ACS, AND, arrays, ASC, ASN, assignment, BASIC, BREAK, CATALOG, CHR$, CLEAR, CLS, comparisons, COS, DATA, DIM, DIR, EDIT, E, END, EXP, FACT, factorial, FALSE, FIX, FOR, GOSUB, GOTO.
HELP, IF, INKEY$, INPUT, INT, KILL, LEFT$, LEN, LET, LIST, LOG, LOWER$, MAX, MEM, MID$, MIN, MOD, NEW, NEXT, NOT, numeric variables, OR, PAUSE, PI, PRINT, PRINT @.
RANDINT, READ, REM, RENAME, RESTORE, RETURN, RIGHT$, RND, ROUND, RUN, SAVE, SAVE ASCII BASIC, INSTR, SGN, SIN, SQR, STEP, string arrays, string variables, STR$, SYSTEM, TAB, TAN, THEN, TRIM$, TRUE, UPPER$, VAL.
The best way to learn BASIC is to modify working programs. Change constants, add output, place values in arrays, create a subroutine, and intentionally trigger an error so you recognize it later. Save each successful stage. The emulator is designed to make experimentation safe: the BREAK control stops runaway programs, and ASCII files make your work portable.
INSTR searches one string for another and returns a 1-based character position. If the search text is not found, it returns 0. The updated web emulator supports the two-argument form used by the current emulator.
INSTR(string, search)PRINT INSTR("HELLO","LL")
A$="SATELLITE_DATABASE.HTML"
PRINT INSTR(A$,".HTML")INSTR("HELLO","LL") returns 3.
The updated emulator allows string expressions to be compared directly in IF conditions. This includes string variables and string functions such as LEFT$, RIGHT$, MID$, UPPER$, LOWER$, and TRIM$.
IF string-expression = string-expression THEN lineIF string-expression <> string-expression THEN line=, <>, <, <=, >, and >=.
10 A$="REPORT.TXT"
20 IF RIGHT$(A$,4)=".TXT" THEN 100
30 END
100 PRINT "TEXT FILE"
110 ENDREM consumes the remainder of its BASIC line. In the updated emulator, a colon appearing after REM is treated as comment text rather than as a separator for another BASIC statement.
10 PRINT "START"
20 REM INPUT FORMAT: ls.txt
30 PRINT "DONE"The text : ls.txt remains part of the comment on line 20 and is not executed as a separate statement.
When a stored BASIC program fails at runtime, the updated emulator reports the BASIC line number, the exact statement that failed, and the statement index within the flattened program. This makes errors in long programs and colon-separated lines easier to locate.
?ERROR IN BASIC LINE 30: EXPECTED =
STATEMENT: ls.txt
STATEMENT INDEX: 4 OF 94Direct-mode errors that are not associated with a stored BASIC line continue to use the shorter ?ERROR: form.
The current emulator provides two virtual drives. Drive 0 is a server-shared disk backed by the Raspberry Pi server API, so files can be shared by different devices that open the same emulator. Drive 1 is browser-local IndexedDB storage and remains private to that browser/device.
DRIVE 0DRIVE 1Drive selection affects FILES, program LOAD/SAVE, file deletion/rename, and the drive captured by a BASIC OPEN statement.
DIRFILESFILES *.BASFILES accepts * and ? wildcards.
LOAD "DEMO.BAS"SAVE "MYPROG.BAS"KILL "MYPROG.BAS"DELETE "MYPROG.BAS"RENAME "OLD.BAS","NEW.BAS"trs80_disk_api.php endpoint and a writable server disk directory. Drive 1 is local browser storage and is not automatically shared with another device.The emulator provides modern command-line editing while retaining the Model 4 terminal appearance. Up to 100 submitted commands are retained in the current session history. Up and Down recall earlier or later commands. Recalled text can be changed before it is submitted again.
| Key | Action |
|---|---|
| Up / Down | Recall previous or later command-history entries. |
| Left / Right | Move the insertion cursor one character. |
| Home / End | Move to the beginning or end of the current input line. |
| Backspace | Delete the character immediately before the cursor. |
| Delete | Delete the character at the cursor. |
| Normal typing | Insert new characters at the current cursor position. |
EDIT 120EDIT n is useful as a quick line editor. If BASIC line 120 exists, the emulator places the complete numbered line onto the editable command line. Move the cursor, delete or insert characters, and press ENTER to replace the stored line.
120 PRINT "HELLO WORLD"
EDIT 120After EDIT 120, modify the recalled 120 PRINT ... text and press ENTER. This avoids creating a separate full-screen editor when ordinary line editing is sufficient.
The EXPORT DISK and IMPORT DISK controls operate on the currently selected virtual drive. Export produces a JSON backup of the selected drive; import restores files from a compatible backup into the selected drive.
DRIVE 0
FILES
[click EXPORT DISK]The exported filename identifies the selected drive. Before importing, select the destination drive with DRIVE 0 or DRIVE 1.
Drive 0 is the emulator's shared server disk. The browser communicates with trs80_disk_api.php, allowing programs and data files saved from one device to be visible from another device using the same server.
DRIVE 0DRIVE 0
FILES
SAVE "TEST.BAS"
FILES
LOAD "TEST.BAS"The PHP disk API must be installed and the server disk directory must be writable by the web-server account. A server/API error is reported as a disk error by the emulator.
DRIVE 1, FILES, LOAD, SAVE, OPEN
Drive 1 uses IndexedDB in the current browser. It persists through ordinary page reloads and browser restarts, but it is not automatically synchronized to another browser or device.
DRIVE 1DRIVE 1
FILES *.BAS
SAVE "LOCAL.BAS"OPEN gives a BASIC program sequential access to a file on the drive that is selected when the statement executes. The emulator supports file numbers 1 through 16.
OPEN "I",#1,"DATA.TXT"OPEN "O",#1,"DATA.TXT"OPEN "A",#1,"DATA.TXT"| Mode | Meaning |
|---|---|
| I | Input. Opens an existing file for sequential reading. |
| O | Output. Starts an output file; data is committed when the file is closed. |
| A | Append. Loads existing contents when present and writes new output at the end. |
The selected drive is remembered by the open file handle. Changing drives after OPEN does not move that already-open handle to another drive.
Bad mode, file number outside 1–16, duplicate open file number, missing input file, or attempting an operation with the wrong file mode.
PRINT # writes evaluated BASIC output to a file opened in output or append mode.
PRINT #1,"RICH"PRINT #1,12345PRINT #1,A$,N10 OPEN "O",#1,"PEOPLE.TXT"
20 A$="RICH"
30 N=65
40 PRINT #1,A$,N
50 CLOSE #1
60 ENDA trailing comma or semicolon suppresses the normal line ending, following the emulator's PRINT-list behavior.
PRINT # requires a file opened with mode O or A.INPUT # reads sequential fields from a file opened for input. Multiple variables may be supplied.
INPUT #1,AINPUT #1,A$,NQuoted text is read as a string field. Unquoted fields are delimited by commas or line endings. Numeric variables are converted with numeric parsing; a value that cannot be parsed numerically becomes zero.
10 OPEN "I",#1,"PEOPLE.TXT"
20 INPUT #1,A$,N
30 PRINT A$;N
40 CLOSE #1
50 ENDEOF() when processing files of unknown length.LINE INPUT # reads an entire text line into a string variable without splitting the line into comma-separated fields.
LINE INPUT #1,A$10 OPEN "I",#1,"NOTES.TXT"
20 IF EOF(1) THEN 60
30 LINE INPUT #1,A$
40 PRINT A$
50 GOTO 20
60 CLOSE #1
70 ENDThe destination must be a string variable.
EOF() tests whether an input file has reached the end of its content. CLOSE releases open file handles and commits output/append data to the selected virtual drive.
EOF(1)EOF(#1)The function returns a BASIC numeric truth value suitable for IF.
CLOSE #1CLOSECLOSE #1 closes one file. CLOSE closes all currently open BASIC files. Output and append files are written back when closed if they have been changed.
10 OPEN "I",#1,"DATA.TXT"
20 IF EOF(1) THEN 60
30 LINE INPUT #1,A$
40 PRINT A$
50 GOTO 20
60 CLOSE #1The virtual drives can now hold both BASIC programs and ordinary sequential data files.
10 OPEN "O",#1,"TEST.TXT"
20 PRINT #1,"RICH"
30 PRINT #1,12345
40 PRINT #1,"TRS-80 MODEL 4"
50 CLOSE #1
60 END10 OPEN "I",#1,"TEST.TXT"
20 LINE INPUT #1,A$
30 INPUT #1,N
40 LINE INPUT #1,B$
50 CLOSE #1
60 PRINT A$
70 PRINT N
80 PRINT B$
90 END10 OPEN "A",#2,"LOG.TXT"
20 PRINT #2,"PROGRAM STARTED"
30 CLOSE #2
40 ENDSelect DRIVE 0 before running when the file should be shared through the server, or DRIVE 1 for browser-local storage.
The current emulator adds browser clipboard conveniences while retaining the terminal interface.
Multi-line BASIC text can be pasted into the emulator. Numbered lines are processed as program lines, allowing a listing copied from an editor to be inserted without typing each line.
Selected terminal text can be copied with the normal browser copy operation. The emulator also provides a program-copy control for copying the stored BASIC listing.
When terminal text is selected, Ctrl+C performs normal copying. When no text is selected during program execution, Ctrl+C remains available as a BREAK request.
This edition documents the current HTML emulator, including the compatibility work added to run programs that also run in the C interpreter.
YY, COUNT, and string names ending in $.11+INT(A).IF...THEN...ELSE statements, including assignments and PRINT statements in either branch.INSTR() string searching.PRINT @ programs such as the fitted sine-wave demonstration.EDIT n to recall a stored BASIC line onto the editable command line.OPEN, CLOSE, PRINT #, INPUT #, LINE INPUT #, and EOF().TAPE:name filenames, a separate tape PHP API, physical trs80_tape storage, buffered large-file writes, and animated tape motion.CLOAD, CSAVE, CLOAD?/TAPE, REWIND/TREW, and TSTOP.RENUM program renumbering with automatic branch-target adjustment.PRINT USING numeric and string formatting.The emulator's Help Manual links should point to trs80_model4_manual.html, the filename of this manual.
TYPE displays a readable file directly from a virtual drive without loading it into BASIC program memory.
TYPE filenameTYPE "filename"TYPE 0:filenameTYPE 1:filenameDRIVE 0
TYPE TEST.TXT
TYPE 0:TEST.TXT
TYPE "1:README.TXT"
TYPE 0:PROGRAM.BASWithout a drive prefix, TYPE uses the current drive. TYPE does not change the BASIC program in memory; LIST still lists the program currently in memory.
COPY copies a file without loading or interpreting it as BASIC. This is useful for moving files between shared Drive 0 and browser-local Drive 1.
COPY "source","destination"COPY "0:TEST.BAS","1:TEST.BAS"
COPY "1:SINEWAVE.BAS","0:SINEWAVE.BAS"
COPY "1:TEST.BAS","0:BACKUP.BAS"The last example copies the file and gives the destination a different name.
PUT and IMPORT open the browser file picker and copy the selected PC file to the currently selected virtual drive. The PC → DRIVE button performs the same operation.
DRIVE 0
PUT
FILES
DRIVE 1
IMPORT
FILESThe original PC filename is used on the virtual drive. The operation is not limited to .BAS files.
GET and EXPORT download one virtual-drive file to the PC. The DRIVE → PC button provides the same operation through a prompt.
GET 0:PROGRAM.CMD
GET 1:DATA.DAT
EXPORT 0:PROGRAM.CMDDRIVE 0
PUT
FILES
COPY "0:PROGRAM.CMD","1:PROGRAM.CMD"
GET 1:PROGRAM.CMDPC import/export uses raw byte data so the virtual drives can store files other than BASIC source.
PROGRAM.CMD
UTILITY.BIN
ROMIMAGE.ROM
DISK.IMG
RECORDS.DAT
NOTES.TXT
PROGRAM.BASPUT/IMPORT reads the PC file as bytes. GET/EXPORT reconstructs those bytes for download. COPY transfers the stored contents between virtual drives without parsing them as BASIC.
The current emulator fixes sequential text output so PRINT # stores actual carriage-return/line-feed characters (CR/LF), not printable backslash-r/backslash-n text.
10 OPEN "O",#1,"TEST.TXT"
20 PRINT #1,"RICH"
30 PRINT #1,12345
40 PRINT #1,"TRS-80 MODEL 4"
50 CLOSE #1
60 ENDTYPE TEST.TXT should display the three values on separate lines. TYPE also normalizes legacy printable \r\n sequences created by older builds.
DRIVE 0
DRIVE 1
DIR
FILES [pattern]
LOAD "PROGRAM.BAS"
SAVE "PROGRAM.BAS"
TYPE "FILE.TXT"
COPY "0:SOURCE","1:DEST"
KILL "FILE"
DELETE "FILE"
RENAME "OLD","NEW"
PUT
IMPORT
GET 0:FILE
EXPORT 1:FILEOPEN "I",#1,"FILE"
OPEN "O",#1,"FILE"
OPEN "A",#1,"FILE"
PRINT #1,...
INPUT #1,...
LINE INPUT #1,A$
EOF(1)
CLOSE #1
CLOSEtrs80_model4.html.The current emulator includes additional compatibility work prompted by testing an original 1979 TRS-80 BIORHYTHM program. The goal is to accept authentic source syntax rather than require old programs to be rewritten for the browser interpreter.
REM: comments consume the remainder of the BASIC line.CLEAR n syntax is accepted.DEFINT and DEFDBL declarations are accepted for source compatibility.INPUT"MONTH (1 TO 12)";M.NEXT may omit the FOR variable.STR$() supplies the leading blank expected for positive values by Microsoft/Radio Shack BASIC programs.AND/OR IF conditions are supported.INKEY$ is available for nonblocking keyboard checks.CHR$(131) and CHR$(149) receive visible browser approximations for the semigraphics used by the BIORHYTHM chart.TAB() now accounts for characters already produced earlier in the same PRINT statement.On Level II BASIC, once a REM statement begins, the remainder of that physical BASIC line is comment text. A colon inside that comment must not be interpreted as a statement separator.
100 REM: BIORHYTHM
110 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELDMANEarlier emulator builds split these lines at the colon and attempted to execute BIORHYTHM as another statement, producing a syntax error. The statement splitter now recognizes REM: and ignores the remainder of the line as executable BASIC.
The parser accepts the original compact Level II syntax with no required space after INPUT:
505 INPUT"MONTH (1 TO 12)";M
520 INPUT"DAY (1 TO 31)";D
540 INPUT"YEAR";YThe spaced form is also accepted.
CLEAR 200On the original machine the numeric argument is associated with BASIC memory/string-space management. The browser interpreter does not require the same physical memory reservation, so the syntax is accepted for compatibility.
DEFINT K,L
DEFDBL B,J,M-ZThese declarations are accepted so original source can run. The browser's JavaScript numeric representation does not reproduce every internal storage distinction of the original machine.
Programs may depend on the leading blank returned for a positive number. The BIORHYTHM date formatter does exactly this:
1080 A$=STR$(M):W=LEN(A$)-1
1090 C$=MID$(A$,2,W)+"/"The current emulator preserves that leading blank for positive STR$() results.
510 M=INT(M):IF M<1 OR M>12 THEN 505
950 IF A$="P" OR A$="E" OR A$="*" THEN C$="*"Logical operators are evaluated around relational conditions so compound numeric and string tests can be used in IF statements.
270 FOR K=1 TO 1000:NEXTThe variable after NEXT is optional, matching the source style used by the original program.
INKEY$ permits a running BASIC program to test the keyboard without issuing an INPUT prompt.
370 PRINT"PRESS 'E' TO END, SPACE TO CONTINUE";
380 R$=INKEY$:IF R$="" THEN 380
390 IF R$="E" THEN 120The BIORHYTHM listing uses CHR$(131) and CHR$(149) while constructing its chart. A modern browser does not use the original TRS-80 video character generator, so the emulator maps these values to visible line-character approximations for the chart display.
750 FOR K=1 TO T+T+1:PRINT CHR$(131);:NEXT
880 L$=LEFT$(L$,T)+CHR$(149)+RIGHT$(L$,T)The BIORHYTHM chart exposed an important PRINT/TAB positioning problem. The date is printed with:
350 PRINT C$;TAB(8);L$Earlier builds calculated TAB(8) from the terminal column that existed before the PRINT statement began. That ignored characters already generated by C$ in the same PRINT statement. The error became visible when the displayed date changed length, such as the transition from 10/9/26 to 10/10/26.
TAB positioning now includes the text already generated earlier in the current PRINT statement. This keeps the chart data aligned instead of allowing a longer date to shift the plotted line unexpectedly.
The original 1979 program is used as a compatibility test for REM parsing, prompted INPUT, CLEAR/DEF declarations, FIX, INKEY$, STR$, string functions, logical OR, NEXT, semigraphics approximations, and PRINT/TAB behavior.
trs80_model4.html.DATE$ and TIME$ return the current local date and time from the computer, tablet, or phone running the web emulator. They are read-only string values and may be used anywhere the emulator accepts a string expression.
Provides the current local calendar date and clock time to BASIC programs and direct-mode commands.
PRINT DATE$PRINT TIME$D$=DATE$T$=TIME$| Function | Format | Example |
|---|---|---|
DATE$ | MM/DD/YYYY | 10/01/2026 |
TIME$ | HH:MM:SS, 24-hour clock | 14:35:08 |
Each reference is evaluated when it is used. DATE$ reads the browser device's local calendar date and formats the month and day as two digits and the year as four digits. TIME$ reads the same device clock and returns two-digit hours, minutes, and seconds using a 24-hour clock.
Because these values come from the host device, their accuracy depends on that device's date, time, and time-zone settings. The emulator does not maintain a separate TRS-80 real-time clock.
DATE$ and TIME$ directly in PRINT statements for timestamps.TIME$ again when a fresh clock value is required; a previously assigned variable does not automatically update.PRINT DATE$
PRINT TIME$
10 PRINT "DATE: ";DATE$
20 PRINT "TIME: ";TIME$
30 END
10 D$=DATE$
20 T$=TIME$
30 PRINT "STARTED ";D$;" AT ";T$
40 ENDThe current emulator provides cassette/reel-to-reel emulation for BASIC program storage and sequential BASIC data files. Sequential files addressed with the TAPE: prefix are stored through the separate server tape API in the physical trs80_tape directory. The animated transport shows tape activity and a six-digit counter.
| Use | Commands | Purpose |
|---|---|---|
| BASIC program storage | CSAVE, CLOAD, CLOAD? | Records, retrieves, and catalogs numbered BASIC programs. |
| Sequential data files | OPEN, PRINT #, INPUT #, LINE INPUT #, EOF(), CLOSE | Writes and reads potentially large sequential data files using TAPE:name. |
/var/www/html/trs80_disk/ Drive 0 files
/var/www/html/trs80_tape/ Sequential tape data files
/var/www/html/trs80_disk_api.php
/var/www/html/trs80_tape_api.php
Drive 0 and tape storage use separate PHP APIs. Drive 1 remains browser-local storage.
TAPE: data files are different tape uses. A large data file written with OPEN "O",#n,"TAPE:name" is not a BASIC program and therefore is not expected to appear as a program in CLOAD?.CSAVE records the BASIC program in memory to tape. CLOAD retrieves a BASIC program from tape and replaces the current in-memory listing.
CSAVE "NAME"CSAVE NAME
CLOAD "NAME"CLOAD NAMECLOAD
CSAVE stores the numbered listing as a BASIC tape entry.CLOAD "NAME" searches for the named BASIC program.CLOAD with no name loads the next BASIC program at or after the current tape position, giving the tape sequential behavior.LIST to inspect the program and RUN to execute it.10 PRINT "HELLO FROM TAPE"
20 END
CSAVE "HELLO"
NEW
CLOAD "HELLO"
LIST
RUN
REWIND
CLOAD
LIST
CLOAD
LIST
SAVE and recording it to tape with CSAVE are separate operations.The tape transport has direct commands and on-screen controls. The counter is six digits so long operations can be observed without quickly wrapping.
CLOAD?
CLOAD? catalogs BASIC programs recorded for CSAVE/CLOAD. It is a program catalog, not a directory of sequential TAPE: data files. Therefore a file such as TAPE:3LEDATA can exist and contain many thousands of records while CLOAD? still reports NO PROGRAMS RECORDED.
TAPETAPE DIR
The current server-backed tape-data implementation uses the separate tape API and the trs80_tape directory for sequential data files.
REWINDTREW
Rewind moves the simulated transport back to the beginning and resets the tape position/counter. Rewinding does not erase a recorded server tape-data file.
TSTOPSTOP TAPE
Stops the simulated transport. The STOP button performs the same operation.
PLAY starts visible transport motion. Use EJECT deliberately according to the current cassette-control implementation.
CLOAD? as a test for whether a sequential TAPE: data file exists. It reports BASIC program recordings.A running BASIC program can use sequential file statements with a filename beginning with TAPE:. These data files are stored on the web server through trs80_tape_api.php, separately from Drive 0.
OPEN "O",#1,"TAPE:DATA"
OPEN "I",#1,"TAPE:DATA"
OPEN "A",#1,"TAPE:DATA"
| Mode | Meaning |
|---|---|
| O | Output: create/replace the named tape data file. |
| I | Input: read an existing tape data file sequentially. |
| A | Append: retain existing contents and add new records at the end. |
PRINT #1,expression
INPUT #1,N
INPUT #1,A$,N
LINE INPUT #1,A$
IF EOF(1) THEN ...
CLOSE #1
The physical server file is kept under /var/www/html/trs80_tape/. The directory must be writable by the web server account (normally www-data on the Raspberry Pi).
sudo mkdir -p /var/www/html/trs80_tape
sudo chown www-data:www-data /var/www/html/trs80_tape
sudo chmod 775 /var/www/html/trs80_tape
Tape reads/writes update the simulated transport and counter. Large output is buffered so records can be committed to the server in groups rather than by issuing an HTTP request for every record.
INPUT PAST END OF FILE. Use EOF() when the record count is not known, and always CLOSE output files so pending buffered data is committed.10 OPEN "O",#1,"TAPE:DATA"
20 PRINT #1,"RICH"
30 PRINT #1,12345
40 CLOSE #1
50 OPEN "I",#1,"TAPE:DATA"
60 INPUT #1,A$
70 INPUT #1,N
80 CLOSE #1
90 PRINT "NAME = ";A$
100 PRINT "NUMBER = ";N
110 END
10 OPEN "I",#1,"3LE.TXT"
20 OPEN "O",#2,"TAPE:3LEDATA"
30 I=0
40 INPUT #1,A$
50 PRINT #2,A$
60 I=I+1
70 IF EOF(1) THEN CLOSE: PRINT I;" RECORDS WRITTEN": END
80 GOTO 40
This form avoids printing a progress message for every record. Screen output inside a 90,000-record loop can dominate execution time even when tape output itself is buffered.
10 OPEN "I",#1,"TAPE:DATA"
20 IF EOF(1) THEN 60
30 INPUT #1,N
40 PRINT N
50 GOTO 20
60 CLOSE #1
70 END
PRINT to the screen on every record.PRINT # tape output is buffered and periodically appended to the physical server file.CLOSE flushes remaining buffered output.RENUM renumbers stored BASIC lines and adjusts supported line-number references so a program can be reorganized without manually repairing ordinary branches.
RENUM
RENUM newStart
RENUM newStart,oldStart,increment
RENUM is equivalent to starting new numbering at 10, considering the program from the beginning, and using an increment of 10.
| Parameter | Description |
|---|---|
newStart | First new line number. Default 10. |
oldStart | Only old lines at or above this value are selected for renumbering. Default 0. |
increment | Spacing between new line numbers. Default 10. |
RENUM
RENUM 100
RENUM 100,50,10
When a line number changes, RENUM also updates the supported numeric targets found in ordinary branch statements. Numbers inside quoted strings and REM comments are not intended as branch targets and are left alone.
GOTO lineGOSUB lineIF condition THEN lineIF condition THEN GOTO lineELSE line and ELSE GOTO line formsRESTORE line where a numeric line target is used by the renumbering pass5 PRINT "START"
7 GOSUB 25
12 IF A=1 THEN 30
20 GOTO 40
25 PRINT "SUB"
27 RETURN
30 PRINT "YES"
40 END
10 PRINT "START"
20 GOSUB 50
30 IF A=1 THEN 60
40 GOTO 80
50 PRINT "SUB"
60 RETURN
70 PRINT "YES"
80 END
RENUM 100,50,10 leaves lines below old line 50 unchanged and renumbers selected lines beginning at 100. References to lines that are actually remapped are adjusted.
PRINT USING provides formatted numeric and string output. It is useful for financial reports, aligned tables, fixed decimal places, signs, currency, and scientific notation.
PRINT USING "format";value
PRINT USING "format";A;B;C
| Pattern | Use |
|---|---|
# | Numeric digit position. |
. | Decimal point; following # positions determine decimal places. |
, | Thousands grouping when included in the format. |
+ / - | Leading or trailing sign control. |
** | Asterisk fill. |
$$ | Currency prefix. |
^^^^ | Scientific notation. |
! prints the first character.& prints the entire string.10 A=1234.5
20 PRINT USING "########.##-";A
30 PRINT USING "$$####.##";A
40 PRINT USING "^^^^";A
50 A$="MODEL 4"
60 PRINT USING "&";A$
A trailing comma or semicolon on the PRINT USING value list suppresses the normal newline in the same spirit as the emulator's PRINT handling.
This checklist includes the current shared/local disk arrangement and the server-backed sequential tape-data changes.
RUN LIST EDIT n RENUM NEW CLEAR CLS
HELP MEM BASIC SYSTEM
DRIVE 0 server-shared drive through trs80_disk_api.php
DRIVE 1 browser-local drive
DIR / CATALOG
FILES [pattern]
LOAD "file"
SAVE "file"
TYPE "file"
COPY "source","destination"
KILL "file" / DELETE "file"
RENAME "old","new"
PUT / IMPORT
GET file / EXPORT file
The Drive 0 PHP API contains the server-side import-size limit. On the current Raspberry Pi installation this was increased from 1 MiB to 50 MiB so multi-megabyte files such as TLE catalogs can be imported.
CLOAD [name]
CSAVE [name]
CLOAD? BASIC-program cassette catalog
TAPE / TAPE DIR
REWIND / TREW
TSTOP / STOP TAPE
OPEN "I",#n,"TAPE:name"
OPEN "O",#n,"TAPE:name"
OPEN "A",#n,"TAPE:name"
PRINT #n,...
INPUT #n,...
LINE INPUT #n,A$
EOF(n) / EOF(#n)
CLOSE #n / CLOSE
Server API: /trs80_tape_api.php
Physical files: /var/www/html/trs80_tape/
CLOAD? reports BASIC program recordings; it should not be interpreted as a directory of sequential TAPE: data files.
Numbered program lines; multi-character numeric and string variables; arrays; LET/assignment; PRINT; PRINT USING; PRINT @; TAB(); INPUT including prompted Level-II-style forms; IF...THEN...ELSE; GOTO; GOSUB/RETURN; FOR/NEXT including NEXT without a variable; DATA/READ/RESTORE; REM-aware colon handling; PAUSE; INKEY$; DATE$; TIME$; math, logical, string, and random functions documented elsewhere in this manual.
DEFINT
DEFSNG
DEFDBL
DEFSTR
CLEAR n
The DEF type declarations are accepted for source compatibility; JavaScript number/string storage does not reproduce every historical Microsoft BASIC numeric storage distinction.