Quick Tiny BASIC reference
Lines without number are executed immediately. Line overwrite previous with same number if it exists.
Valid variable names are capital letters from A to Z
Math operators are +
, -
(unary and binary), /
, *
.
Comparison operators are =
, >
, >=
, <
, <=
, <>
Main operators
- PRINT expr|string, expr|string, ...
- Outputs expression result or string
- INPUT var-1, var-2, ...
- Read number from input to variable
- LET var = expr
- Calculates expression and put result in variable
- GOTO lineNumber
- Jump to specified line number
- GOSUB lineNumber
- Jump to specified line number and save current for return
- RETURN
- Jump to line after last executed GOSUB operator
- IF expr comparison expr THEN statement
- Execute statement if comparison result is true
- END
- Stop execution and jump to start
- RUN
- Execute store program lines starting from lowest
- CLEAR
- Clear variables and program
More details about TinyBASIC: https://en.wikipedia.org/wiki/Tiny_BASIC and http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html
Extensions
Some extensions are based on Tom Pittman interpreter
Variable can be declared as array using DIM operator. Expression A(X)
should be used for accessing or assignment, where A
is array variable name and X
is expression used as index.
Functions
Functions can be used in calculated expressions
- RND(x)
- Returns random number from 0 to x
- ASC("L")
- Returns ASCII code of letter L
- USR(expr, expr, ...)
- Calls user-defined function and return result
Operators
- REM anything
- Commentary, skipped by interpreter
- DIM var(size)
- Declare variable as array of specified size (can be expression)