isbas BASIC help
"isbas" is derived from "ippleSoft BASIC", an AppleSoft-compatible
BASIC interpreter which
runs on the iPhone's
web browser. The original source
is available under
GPL v2. This
version has been modified to operate on the Sony
COM-2 "mylo" communicator.
Changes from the original version include...
- Single screen for both input and output (rather than separate
input and output boxes) to permit entry on the COM-2 without having to
click first. Plus I just like the look and feel of old-style BASIC. At
the moment there is no cursor, but text is always added to the end of
the existing output.
- Screen is set to auto-advance without showing scroll bars to make
up for the COM-2's apparent inability to auto-scroll a text area to the
end, and also prevent possible build-up of too much data. On the COM-2
this isn't perfect but works so long as text lines are short enough to
page source in a regular browser (or load it into a plain text editor)
to see the source.
- No longer autosaves and autoruns the HELLO "cookie" program,
instead it loads and runs whatever program is encoded into the source.
- Added partial implementations of INPUT and GET. These must be the
last statement on a line, and there is no support for printing INPUT
- Added buttons to permit operating numerical programs without
using the keyboard.
The COM-2 does not issue key events for space and backspace via the
usual onkeydown and onkeypress events, these are defined and work fine
in Firefox, Mozilla etc but aliases have been defined for the COM-2 to
permit using the back arrow for backspace and the forward arrow for
- Separates multiple statements on the same line.
- Indicates a REMark, or comment. Any remaining text on the line is
- Erases the current program and clears all variables
- Resets all variables.
- Displays the entire current program.
- LIST lineno
- Displays the line at lineno.
- LIST start-end
- Displays the lines from start to end.
- Executes the current program.
- LET A=expr
- Stores the value of expr in A. LET is optional.
- GOTO lineno
- Branch to line lineno.
- IF expr THEN s1:s2:s3
- Executes statements s1:s2:s3 if expr is true.
- FOR v=x TO y STEP z
- Loop across all values of v from x to y,
incrementing by z. If STEP is omitted, 1 is used.
- Repeats last loop.
- NEXT x
- Repeats last loop for variable x.
- GOSUB lineno
- Branch to subroutine at line lineno.
- Returns to point of call from a subroutine.
- Removes one address from the return stack.
- Re-executes statement causing an error.
- Halts program and prints line number.
- Resumes program execution.
- Halts program execution.
- Clears the screen.
- PRINT expr
- Prints strings and/or mathematical expressions, use ; to separate
strings or suppress newline.
- INPUT A
- Sets a variable to an entered number or expression. If nothing
entered 0 is assumed.
- INPUT A$
- Sets a string variable to an entered string. Quotes (") are not
- GET A$
- Captures a single keystroke into a string variable. If enter
pressed sets to empty string.
- Real number in the range +/- 9.9999999 E+37
- Integer in the range +/- 32767
- String from 0 to 255 characters
- Addition or string concatenation
- Logical AND
- Logical OR
- Logical NOT
- Equal to
- Not equal to
- Less than
- Less than or equal to
- Greater than
- Greater than or equal to
- Absolute value of x
- Sign of x: -1 if x<0, 0 if x=0, 1 if x>0
- Integer portion of x
- Square root of x
- Sine of x
- Cosine of x
- Tangent of x
- Arctangent of x
- Euler's constant e to the xth power
- Natural logarithm of x
- If x>0, random number between 0 and 1. If x=0,
repeat last random number. If x<0, set new random seed.
- FN A(x)
- Executes function A previously defined by DEF FN.
- Length of string A$
- Leftmost x characters of string A$
- y characters of string A$, beginning at position x
- Rightmost x characters of string A$
- String representing x
- Numeric value of string A$
- Character with ASCII code x
- ASCII code of first character in string A$
Programs can be saved and loaded from browser cookies, file size is
limited to 4000 bytes after encoding. Due to the nature of cookies DO
NOT TRUST them to be permanent! Some way needs to be devised to permit
saving and loading files in a more permanent fashion but at the moment
itself to replace the built-in program. Note that the COM-2
with the NetFront 3.4 browser is able to "run" an HTML app such as this
with a .txt extension to permit editing using the built-in text editor,
just manually specify the page in a form like
file:///c/path/to/isbas.txt then bookmark it, or add a .html file that
links to the .txt file.
Lists available programs.
Loads a program.
Loads and runs a program.
Saves a program.
Renames a program.
INPUT and GET were added by me to get by but they are not proper
implementations. INPUT cannot print prompt text, use a PRINT before it
to print the prompt. INPUT and GET must be the last statements on a
line, additional statements afterwards will be ignored due to the way
they work - they halt execution then set the requested variables in
immediate mode then continue running the program. Best I can figure out
at the moment but they're much better than having to enter data by
setting variables in immediate mode. Also required no modification to
the interpreter code itself other than adding code for the commands, so
was the least risky way to hook it in.
All numbers must begin with 0 to 9 or minus, not period. Enter
numbers between 0 and 1 as 0.something.
To specify a number in scientific notation such as 1.5E-25, enter it
as 1.5*10^(-25). Note that the exponent must be in parenthesis if
fractional or negative.
DIM is not implemented. Starting code for it is present in the
source but no idea how to finish it.
The screen elements have been formatted to fit the COM-2 screen with
minimum text size set to 18 or less. To use bigger text or to format
for other mobile devices adjust the rows and cols setting in the
initial textarea html tag. Not sure how it works now on an iPhone, in
particular if the key handlers will function in that environment.
iPhone is a registered trademark
of Apple Inc.
"mylo" is a registered trademark of the Sony Corporation.
These notes last modified 5/19/08.