Output from HELP:
This is EndBASIC X.Y.Z.
Project page at
License Apache Version 2.0
[38;5;11m Top-level help topics
[39m
>> [38;5;14mArray functions
[39m >> [38;5;14mCloud access
[39m >> [38;5;14mConsole
[39m >> [38;5;14mData management
[39m >> [38;5;14mFile system
[39m >> [38;5;14mGraphics
[39m >> [38;5;14mHardware interface
[39m >> [38;5;14mInterpreter
[39m >> [38;5;14mLanguage reference
[39m >> [38;5;14mNumerical functions
[39m >> [38;5;14mStored program
[39m >> [38;5;14mString and character functions
[39m
Type HELP followed by the name of a topic for details.
Type HELP "HELP" for details on how to specify topic names.
Type LOAD "DEMOS:/TOUR.BAS": RUN for a guided tour.
Type END or press CTRL+D to exit.
Output from HELP "ARRAY":
[38;5;11m Array functions
[39m
>> [38;5;14mLBOUND%[39m Returns the lower bound for the given dimension of the array.
>> [38;5;14mUBOUND%[39m Returns the upper bound for the given dimension of the array.
Type HELP followed by the name of a topic for details.
Output from HELP "CLOUD":
[38;5;11m Cloud access
[39m
The EndBASIC service is a cloud service that provides online file
sharing across users of EndBASIC and the public.
Files that have been shared publicly can be accessed without an account
via the cloud:// file system scheme. All you have to do is mount a
user's cloud drive and then access the files as you would with your
own. For example:
MOUNT "X", "cloud://user-123": DIR "X:"
To upload files and share them, you need to create an account. During
account creation time, you are assigned a unique, persistent drive in
which you can store files privately. You can later choose to share
individual files with the public or with specific individuals, at which
point those people will be able to see them by mounting your drive.
If you have any questions or experience any problems while interacting
with the cloud service, please contact support@endbasic.dev.
>> [38;5;14mLOGIN [39m Logs into the user's account.
>> [38;5;14mLOGOUT[39m Logs the user out of their account.
>> [38;5;14mSHARE [39m Displays or modifies the ACLs of a file.
>> [38;5;14mSIGNUP[39m Creates a new user account interactively.
Type HELP followed by the name of a topic for details.
Output from HELP "CONSOLE":
[38;5;11m Console
[39m
The EndBASIC console is the display you are seeing: both the
interpreter and the effects of all commands happen within the same
console. There is no separate output window as other didactical
interpreters provide. This unified console supports text and,
depending on the output backend, graphics. This help section focuses
on the textual console; for information about graphics, run HELP
"GRAPHICS".
The text console is a matrix of variable size. The upper left position
is row 0 and column 0. Each position in this matrix contains a
character and a color attribute. The color attribute indicates the
foreground and background colors of that character. There is a default
attribute to match the default settings of your terminal, which might
not be a color: for example, in a terminal emulator configured with a
black tint (aka a transparent terminal), the default color respects the
transparency whereas color 0 (black) does not.
If you are writing a script and do not want the script to interfere
with other parts of the console, you should restrict the script to
using only the INPUT and PRINT commands.
Be aware that the console currently reacts poorly to size changes.
Avoid resizing your terminal or web browser. If you do resize them,
however, restart the interpreter.
>> [38;5;14mCLS [39m Clears the screen.
>> [38;5;14mCOLOR [39m Sets the foreground and background colors.
>> [38;5;14mINKEY$ [39m Checks for an available key press and returns it.
>> [38;5;14mINPUT [39m Obtains user input from the console.
>> [38;5;14mLOCATE [39m Moves the cursor to the given position.
>> [38;5;14mPRINT [39m Prints one or more values to the console.
>> [38;5;14mSCRCOLS%[39m Returns the number of columns in the text console.
>> [38;5;14mSCRROWS%[39m Returns the number of rows in the text console.
Type HELP followed by the name of a topic for details.
Output from HELP "DATA":
[38;5;11m Data management
[39m
>> [38;5;14mREAD [39m Extracts data values from DATA statements.
>> [38;5;14mRESTORE[39m Resets the index of the data element to be returned.
Type HELP followed by the name of a topic for details.
Output from HELP "FILE SYSTEM":
[38;5;11m File system
[39m
The EndBASIC storage subsystem is organized as a collection of drives,
each identified by a case-insensitive name. Drives can be backed by a
multitude of file systems with different behaviors, and their targets
are specified as URIs. Special targets include: memory://, which
points to an in-memory read/write drive; and demos://, which points to
a read-only drive with sample programs. Other targets may be available
such as file:// to access a local directory or local:// to access
web-local storage, depending on the context. The output of the MOUNT
command can help to identify which targets are available.
All commands that operate with files take a path. Paths in EndBASIC
can be of the form FILENAME.EXT, in which case they refer to a file in
the current drive; or DRIVE:/FILENAME.EXT and DRIVE:FILENAME.EXT, in
which case they refer to a file in the specified drive. Note that the
slash before the file name is currently optional because EndBASIC does
not support directories yet. Furthermore, if .EXT is missing, a .BAS
extension is assumed.
Be aware that the commands below must be invoked using proper EndBASIC
syntax. In particular, this means that path arguments must be
double-quoted and multiple arguments have to be separated by a comma
(not a space). If you have used commands like CD, DIR, or MOUNT in
other contexts, this is likely to confuse you.
See the "Stored program" help topic for information on how to load,
modify, and save programs.
>> [38;5;14mCD [39m Changes the current path.
>> [38;5;14mDIR [39m Displays the list of files on the current or given path.
>> [38;5;14mMOUNT [39m Lists the mounted drives or mounts a new drive.
>> [38;5;14mPWD [39m Prints the current working location.
>> [38;5;14mUNMOUNT[39m Unmounts the given drive.
Type HELP followed by the name of a topic for details.
Output from HELP "GRAPHICS":
[38;5;11m Graphics
[39m
The EndBASIC console overlays text and graphics in the same canvas.
The consequence of this design choice is that the console has two
coordinate systems: the character-based system, used by
the commands described in HELP "CONSOLE", and the pixel-based system,
used by the commands described in this section.
>> [38;5;14mGFX_CIRCLE [39m Draws a circle of radius r centered at (x,y).
>> [38;5;14mGFX_CIRCLEF[39m Draws a filled circle of radius r centered at (x,y).
>> [38;5;14mGFX_HEIGHT%[39m Returns the height in pixels of the graphical console.
>> [38;5;14mGFX_LINE [39m Draws a line from (x1,y1) to (x2,y2).
>> [38;5;14mGFX_PIXEL [39m Draws a pixel at (x,y).
>> [38;5;14mGFX_RECT [39m Draws a rectangle from (x1,y1) to (x2,y2).
>> [38;5;14mGFX_RECTF [39m Draws a filled rectangle from (x1,y1) to (x2,y2).
>> [38;5;14mGFX_SYNC [39m Controls the video syncing flag and/or forces a sync.
>> [38;5;14mGFX_WIDTH% [39m Returns the width in pixels of the graphical console.
Type HELP followed by the name of a topic for details.
Output from HELP "HARDWARE":
[38;5;11m Hardware interface
[39m
EndBASIC provides features to manipulate external hardware. These
features are currently limited to GPIO interaction on a Raspberry Pi
and are only available when EndBASIC has explicitly been built with the
--features=rpi option. Support for other busses and platforms may come
later.
>> [38;5;14mGPIO_CLEAR[39m Resets the GPIO chip or a specific pin.
>> [38;5;14mGPIO_READ?[39m Reads the state of a GPIO pin.
>> [38;5;14mGPIO_SETUP[39m Configures a GPIO pin for input or output.
>> [38;5;14mGPIO_WRITE[39m Sets the state of a GPIO pin.
Type HELP followed by the name of a topic for details.
Output from HELP "INTERPRETER":
[38;5;11m Interpreter
[39m
>> [38;5;14mCLEAR [39m Restores initial machine state but keeps the stored program.
>> [38;5;14mERRMSG$[39m Returns the last captured error message.
>> [38;5;14mHELP [39m Prints interactive help.
>> [38;5;14mSLEEP [39m Suspends program execution.
Type HELP followed by the name of a topic for details.
Output from HELP "LANG":
[38;5;11m General language topics
[39m
>> [38;5;14mDO [39m Do loops
>> [38;5;14mExpressions[39m Expressions and operators
>> [38;5;14mFOR [39m For loops
>> [38;5;14mFunctions [39m User-defined functions
>> [38;5;14mIF [39m Multiline and uniline IF statements
>> [38;5;14mJumps [39m GOTO, GOSUB, END, and labels
>> [38;5;14mON ERROR [39m Error handling
>> [38;5;14mSELECT CASE[39m Conditional statement to choose among values
>> [38;5;14mStyle [39m Spacing, comments, and general style
>> [38;5;14mSubroutines[39m User-defined subroutines
>> [38;5;14mTypes [39m Primitive types and arrays
>> [38;5;14mVariables [39m Variable references, assignments, and the DIM keyword
>> [38;5;14mWHILE [39m While loops
Type HELP followed by the name of a topic for details.
Output from HELP "NUMERICAL":
[38;5;11m Numerical functions
[39m
>> [38;5;14mATN# [39m Computes the arc-tangent of a number.
>> [38;5;14mCINT% [39m Casts the given numeric expression to an integer (with rounding).
>> [38;5;14mCOS# [39m Computes the cosine of an angle.
>> [38;5;14mDEG [39m Sets degrees mode of calculation.
>> [38;5;14mINT% [39m Casts the given numeric expression to an integer (with truncation).
>> [38;5;14mMAX# [39m Returns the maximum number out of a set of numbers.
>> [38;5;14mMIN# [39m Returns the minimum number out of a set of numbers.
>> [38;5;14mPI# [39m Returns the Archimedes' constant.
>> [38;5;14mRAD [39m Sets radians mode of calculation.
>> [38;5;14mRANDOMIZE[39m Reinitializes the pseudo-random number generator.
>> [38;5;14mRND# [39m Returns a random number in the [0..1] range.
>> [38;5;14mSIN# [39m Computes the sine of an angle.
>> [38;5;14mSQR# [39m Computes the square root of the given number.
>> [38;5;14mTAN# [39m Computes the tangent of an angle.
Type HELP followed by the name of a topic for details.
Output from HELP "STORED":
[38;5;11m Stored program
[39m
The EndBASIC interpreter has a piece of read/write memory called the
"stored program". This memory serves to maintain the code of a program
you edit and manipulate right from the interpreter.
The common flow to interact with a stored program is to load a program
from disk using the LOAD command, modify its contents via the EDIT
command, execute the program via the RUN command, and finally save the
new or modified program via the SAVE command.
Be aware that the stored program's content is lost whenever you load a
program, exit the interpreter, or use the NEW command. These
operations will ask you to save the program if you have forgotten to do
so, but it's better to get in the habit of saving often.
See the "File system" help topic for information on where the programs
can be saved and loaded from.
>> [38;5;14mDISASM[39m Disassembles the stored program.
>> [38;5;14mEDIT [39m Interactively edits the stored program.
>> [38;5;14mKILL [39m Deletes the given program.
>> [38;5;14mLIST [39m Prints the currently-loaded program.
>> [38;5;14mLOAD [39m Loads the given program.
>> [38;5;14mNEW [39m Restores initial machine state and creates a new program.
>> [38;5;14mRUN [39m Runs the stored program.
>> [38;5;14mSAVE [39m Saves the current program in memory to the given filename.
Type HELP followed by the name of a topic for details.
Output from HELP "STRING":
[38;5;11m String and character functions
[39m
>> [38;5;14mASC% [39m Returns the UTF character code of the input character.
>> [38;5;14mCHR$ [39m Returns the UTF character that corresponds to the given code.
>> [38;5;14mLEFT$ [39m Returns a given number of characters from the left side of a string.
>> [38;5;14mLEN% [39m Returns the length of the string in expr$.
>> [38;5;14mLTRIM$[39m Returns a copy of a string with leading whitespace removed.
>> [38;5;14mMID$ [39m Returns a portion of a string.
>> [38;5;14mRIGHT$[39m Returns a given number of characters from the right side of a string.
>> [38;5;14mRTRIM$[39m Returns a copy of a string with trailing whitespace removed.
>> [38;5;14mSTR$ [39m Formats a scalar value as a string.
Type HELP followed by the name of a topic for details.
Output from HELP "DO":
[38;5;11m Do loops
[39m
`DO` loops are a generalized form of `WHILE` loops. `DO` loops allow
testing a condition before or after every iteration, and the condition
can be tested until it is true or false. Take a look at the following
examples:
DO
PRINT "Infinite loop"
LOOP
DO
a = a + 1
LOOP UNTIL a = 10
DO
a = a + 1
LOOP WHILE a < 10
a = 0
DO UNTIL a = 10
a = a + 1
LOOP
a = 0
DO WHILE a < 10
a = a + 1
LOOP
`DO` loops can be exited an any point via the `EXIT DO` statement.
Output from HELP "EXPRESSIONS":
[38;5;11m Expressions and operators
[39m
EndBASIC provides the following operators:
* Numeric operators:
* Binary infix: +, -, *, /, MOD, ^
* Unary prefix: -
* Logical and bitwise operators:
* Binary infix: AND, OR, XOR
* Unary prefix: NOT
* Whether these perform a logical or bitwise operation depends on
the expression context.
* Bitwise operators:
* Binary infix: <<, >> (signed integer shift without rotation)
* Relational operators:
* Binary infix: =, <>, <, <=, >, >=
Expressions can also contain variable references, function calls, and
array element references. For example, the following defines an array
of doubles, sets one of them, and then reads the value in an expression
and rounds it to an integer via the `CINT` builtin function:
DIM floats(5) AS DOUBLE
floats(2) = 5.6
PRINT 3 + 9 - CINT(floats(2))
Output from HELP "FOR":
[38;5;11m For loops
[39m
`FOR` loops provide iteration through a numeric range. Their most
basic form looks like this:
FOR a = 1 to 10
PRINT a
NEXT
You can optionally specify a positive or negative `STEP` to change how
the iterator changes in each loop body execution:
FOR a = 10 to 1 STEP -2
PRINT a
NEXT
Output from HELP "FUNCTIONS":
[38;5;11m User-defined functions
[39m
To define a function, use the `FUNCTION` keyword followed by an
arbitrary list of argument definitions. Argument declarations can use
type annotations or `AS type` suffixes to define their types, but not
both in a single argument. The return value of a function is specified
by assigning a value to the variable named after the function:
FUNCTION my_function#(b AS BOOLEAN, i%)
IF b THEN my_function = i * 2.3 ELSE my_function = 1.1
END FUNCTION
PRINT my_function(TRUE, 5) ' Prints 11.5.
PRINT my_function(FALSE, 8) ' Prints 1.1.
Global variables can be defined via the `DIM SHARED` keyword. See the
"Variables" help topic for details.
Output from HELP "IF":
[38;5;11m Multiline and uniline IF statements
[39m
Multiline IF statements look like the following. Note that the
`ELSEIF` and `ELSE` clauses are all optional, but if `ELSE` is present,
it must appear last and only once:
IF a = 1 THEN
PRINT "a is 1"
ELSEIF a <> 2 THEN
PRINT "a is not 2"
ELSE
PRINT "a is something else"
END IF
IF statements can be collapsed into a single line and look like the
following. Similarly to the previous, the `ELSE` clause is optional
and can only appear once:
IF a = 1 THEN PRINT "a is 1" ELSE PRINT "a is something else"
Note that, in the uniline form, only a subset of statements can be
specified.
Output from HELP "JUMPS":
[38;5;11m GOTO, GOSUB, END, and labels
[39m
EndBASIC statements can be labeled via explicitly-assigned line numbers
or textual identifiers. These labels can be used as the target of the
unstructured control flow statements `GOTO` and `GOSUB`. For example:
i = 1
20 PRINT i ' Statement with a numeric label.
IF i = 10 THEN GOTO @out
i = i + 1
GOTO 20
@out ' Statement with a textual label.
When using `GOSUB` to temporarily jump to a subroutine, use the
`RETURN` keyword when done:
GOTO @main
@add
result = a + b
RETURN
@main
a = 3: b = 5: GOSUB @add
PRINT result
Program execution can be terminated at any point via the `END`
statement, which optionally takes an exit code to return to the calling
program.
Output from HELP "ON ERROR":
[38;5;11m Error handling
[39m
Certain types of errors can be caught for inspection and program
recovery.
To jump to a line number or label when a recoverable error is caught:
ON ERROR GOTO 100
ON ERROR GOTO @label
To continue execution at the next statement after an error is caught:
ON ERROR RESUME NEXT
To reset the error handler to its default, which terminates program
execution on an error:
ON ERROR GOTO 0
The ERRMSG function can be used to fetch the textual description of the
string that was caught.
Output from HELP "SELECT CASE":
[38;5;11m Conditional statement to choose among values
[39m
The SELECT CASE statement allows evaluating an expression and comparing
it to multiple different values or ranges.
INPUT "Enter a number"; a
SELECT CASE a
CASE 1, 3, 5, 7, 9
PRINT "Odd"
CASE 0, 2, 5, 6, 8
PRINT "Even"
CASE IS < 0, 10 TO 100
PRINT "Other cases"
CASE ELSE
PRINT "Fallback"
END SELECT
The expression given to `SELECT CASE` is evaluated exactly once.
Similarly to `IF` statements, the `CASE ELSE`, if present, must appear
only once at as the last case guard.
When using the `IS` guard, all relational operators can be specified.
Output from HELP "SUBROUTINES":
[38;5;11m User-defined subroutines
[39m
To define a subroutine (also known as procedure or command), use the
`SUB` keyword followed by an arbitrary list of argument definitions.
Argument declarations can use type annotations or `AS type` suffixes to
define their types, but not both in a single argument:
SUB my_command(b AS BOOLEAN, i%)
IF b THEN PRINT i * 2.3 ELSE PRINT 1.1
END SUB
my_command TRUE, 5 ' Prints 11.5.
my_command FALSE, 8 ' Prints 1.1.
Global variables can be defined via the `DIM SHARED` keyword. See the
"Variables" help topic for details.
Output from HELP "STYLE":
[38;5;11m Spacing, comments, and general style
[39m
Every statement in EndBASIC must appear in its own line. Lines can be
separated by natural newline characters, but also via the `:`
character. The following are equivalent:
PRINT 3
PRINT 4
PRINT 3: PRINT 4
Comments can be introduced via `REM` or an apostrophe character and run
throughout the end of a line:
' This is a comment.
REM This is another comment.
a = 3 ' Comment after statement.
The common EndBASIC style in documentation and sample programs is to:
* Write all language keywords in uppercase.
* Write all variable identifiers in lowercase.
* Suffix all variable references and function calls with a type
identifier.
These are just style guidelines and they are neither required nor
enforced in your own code. For a more modern look, you can type all
code in lowercase letters and avoid type identifiers.
Output from HELP "TYPES":
[38;5;11m Primitive types and arrays
[39m
EndBASIC supports the following primitive types:
* `?`: BOOLEAN
* Literal values are `TRUE` and `FALSE`.
* `#`: DOUBLE
* 64-bit double floating point.
* Literal values have the form 123.4.
* `%`: INTEGER
* 32-bit signed integers.
* Literal values can be specified in binary (`b`), decimal (`d`),
octal (`o`) and hexadecimal (`x`) bases.
* Literal values have the form 123, &d123, or &d_123, where `d`
specifies the base.
* `$`: STRING
* Literal values are UTF-8 double-quoted strings.
* Nested double-quotes can be escaped with a `\` character.
Multidimensional arrays are supported as well, although all the
dimensions in an array must have the same type.
Integers are automatically promoted to floats when they appear in a
float expression, and floats are demoted to integers via rounding (3.4
becomes 3, 3.5 becomes 4) when they appear in an integer expression.
Output from HELP "VARIABLES":
[38;5;11m Variable references, assignments, and the DIM keyword
[39m
Variable identifiers are alphanumeric words that start with a letter or
special character such as _. Variable references can optionally be
suffixed by a type identifier to force them to be of a specific type,
but note that EndBASIC is strictly typed and variables cannot change
type after they have been assigned.
Variables can be first defined either via an assignment or via the
`DIM` keyword, the latter of which sets the variable to its zero value.
The following are all equivalent:
DIM foo AS BOOLEAN
DIM foo? AS BOOLEAN
foo? = FALSE
Arrays must be defined with the `DIM` keyword before they can be used.
The following example defines a matrix and sets the value of a single
element within it:
DIM matrix%(10, 100) AS INTEGER
matrix%(5, 15) = 1234
Global variables can be defined via `DIM SHARED` and will be readable
and settable from within user-defined functions:
DIM SHARED global AS DOUBLE
Output from HELP "WHILE":
[38;5;11m While loops
[39m
The `WHILE` keyword is used to define a loop that executes a collection
of statements until a guard condition is false. They look like this:
a = 0
WHILE a < 10
PRINT a
a = a + 1
WEND
Output from HELP "CD":
[38;5;11m CD path$
[39m
Changes the current path.
Output from HELP "CLEAR":
[38;5;11m CLEAR
[39m
Restores initial machine state but keeps the stored program.
This command resets the machine to a semi-pristine state by clearing
all user-defined variables and restoring the state of shared resources.
These resources include: the console, whose color and video syncing bit
are reset; and the GPIO pins, which are set to their default state.
The stored program is kept in memory. To clear that too, use NEW (but
don't forget to first SAVE your program!).
This command is for interactive use only.
Output from HELP "CLS":
[38;5;11m CLS
[39m
Clears the screen.
Output from HELP "COLOR":
[38;5;11m COLOR <> | | <[fg%], [bg%]>
[39m
Sets the foreground and background colors.
Color numbers are given as ANSI numbers and can be between 0 and 255.
If a color number is not specified, then the color is reset to the
console's default. The console default does not necessarily match any
other color specifiable in the 0 to 255 range, as it might be
transparent.
Output from HELP "DEG":
[38;5;11m DEG
[39m
Sets degrees mode of calculation.
The default condition for the trigonometric functions is to use
radians. DEG configures the environment to use degrees until
instructed otherwise.
Output from HELP "DIR":
[38;5;11m DIR <> |
[39m
Displays the list of files on the current or given path.
Output from HELP "DISASM":
[38;5;11m DISASM
[39m
Disassembles the stored program.
The assembly code printed by this command is provided as a tool to
understand how high level code gets translated to the machine code of a
fictitious stack-based machine. Note, however, that the assembly code
cannot be reassembled nor modified at this point.
Output from HELP "EDIT":
[38;5;11m EDIT
[39m
Interactively edits the stored program.
Output from HELP "GFX_CIRCLE":
[38;5;11m GFX_CIRCLE x%, y%, r%
[39m
Draws a circle of radius r centered at (x,y).
The outline of the circle is drawn using the foreground color as
selected by COLOR and the area of the circle is left untouched.
Output from HELP "GFX_CIRCLEF":
[38;5;11m GFX_CIRCLEF x%, y%, r%
[39m
Draws a filled circle of radius r centered at (x,y).
The outline and area of the circle are drawn using the foreground color
as selected by COLOR.
Output from HELP "GFX_LINE":
[38;5;11m GFX_LINE x1%, y1%, x2%, y2%
[39m
Draws a line from (x1,y1) to (x2,y2).
The line is drawn using the foreground color as selected by COLOR.
Output from HELP "GFX_PIXEL":
[38;5;11m GFX_PIXEL x%, y%
[39m
Draws a pixel at (x,y).
The pixel is drawn using the foreground color as selected by COLOR.
Output from HELP "GFX_RECT":
[38;5;11m GFX_RECT x1%, y1%, x2%, y2%
[39m
Draws a rectangle from (x1,y1) to (x2,y2).
The outline of the rectangle is drawn using the foreground color as
selected by COLOR and the area of the rectangle is left untouched.
Output from HELP "GFX_RECTF":
[38;5;11m GFX_RECTF x1%, y1%, x2%, y2%
[39m
Draws a filled rectangle from (x1,y1) to (x2,y2).
The outline and area of the rectangle are drawn using the foreground
color as selected by COLOR.
Output from HELP "GFX_SYNC":
[38;5;11m GFX_SYNC <> |
[39m
Controls the video syncing flag and/or forces a sync.
With no arguments, this command triggers a video sync without updating
the video syncing flag. When enabled? is specified, this updates the
video syncing flag accordingly and triggers a video sync if enabled? is
TRUE.
When video syncing is enabled, all console commands immediately refresh
the console. This is useful to see the effects of the commands right
away, which is why this is the default mode in the interpreter.
However, this is a *very* inefficient way of drawing.
When video syncing is disabled, all console updates are buffered until
video syncing is enabled again. This is perfect to draw complex
graphics efficiently. If this is what you want to do, you should
disable syncing first, render a frame, call GFX_SYNC to flush the
frame, repeat until you are done, and then enable video syncing again.
Note that the textual cursor is not visible when video syncing is
disabled.
WARNING: Be aware that if you disable video syncing in the interactive
interpreter, you will not be able to see what you are typing any longer
until you reenable video syncing.
Output from HELP "GPIO_CLEAR":
[38;5;11m GPIO_CLEAR <> |
[39m
Resets the GPIO chip or a specific pin.
If no pin% is specified, resets the state of all GPIO pins. If a pin%
is given, only that pin is reset. It is OK if the given pin has never
been configured before.
Output from HELP "GPIO_SETUP":
[38;5;11m GPIO_SETUP pin%, mode$
[39m
Configures a GPIO pin for input or output.
Before a GPIO pin can be used for reads or writes, it must be
configured to be an input or output pin. Additionally, if pull up or
pull down resistors are available and desired, these must be configured
upfront too.
The mode$ has to be one of "IN", "IN-PULL-DOWN", "IN-PULL-UP", or
"OUT". These values are case-insensitive. The possibility of using
the pull-down and pull-up resistors depends on whether they are
available in the hardware, and selecting these modes will fail if they
are not.
It is OK to reconfigure an already configured pin without clearing its
state first.
Output from HELP "GPIO_WRITE":
[38;5;11m GPIO_WRITE pin%, value?
[39m
Sets the state of a GPIO pin.
A FALSE value? sets the pin to low, and a TRUE value? sets the pin to
high.
Output from HELP "HELP":
[38;5;11m HELP <> |
[39m
Prints interactive help.
Without arguments, shows a summary of all available top-level help
topics.
With a single argument, which must be a string, shows detailed
information about the given help topic, command, or function.
Topic names are case-insensitive and can be specified as prefixes, in
which case the topic whose name starts with the prefix will be shown.
For example, the following invocations are all equivalent: HELP "CON",
HELP "console", HELP "Console manipulation".
Output from HELP "INPUT":
[38;5;11m INPUT | <[prompt$] <,|;> vref>
[39m
Obtains user input from the console.
The first expression to this function must be empty or evaluate to a
string, and specifies the prompt to print. If this first argument is
followed by the short `;` separator, the prompt is extended with a
question mark.
The second expression to this function must be a bare variable
reference and indicates the variable to update with the obtained input.
Output from HELP "KILL":
[38;5;11m KILL filename$
[39m
Deletes the given program.
The filename must be a string and must be a valid EndBASIC path. The
.BAS extension is optional but, if present, it must be .BAS.
See the "File system" help topic for information on the path syntax.
Output from HELP "LIST":
[38;5;11m LIST
[39m
Prints the currently-loaded program.
Output from HELP "LOAD":
[38;5;11m LOAD filename$
[39m
Loads the given program.
The filename must be a string and must be a valid EndBASIC path. The
.BAS extension is optional but, if present, it must be .BAS.
Any previously stored program is discarded from memory, but LOAD will
pause to ask before discarding any unsaved modifications.
See the "File system" help topic for information on the path syntax.
Output from HELP "LOCATE":
[38;5;11m LOCATE column%, row%
[39m
Moves the cursor to the given position.
Output from HELP "LOGIN":
[38;5;11m LOGIN |
[39m
Logs into the user's account.
On a successful login, this mounts your personal drive under the
CLOUD:/ location, which you can access with any other file-related
commands. Using the cloud:// file system scheme, you can mount other
people's drives with the MOUNT command.
To create an account, use the SIGNUP command.
Output from HELP "LOGOUT":
[38;5;11m LOGOUT
[39m
Logs the user out of their account.
Unmounts the CLOUD drive that was mounted by the LOGIN command. As a
consequence of this, running LOGOUT from within the CLOUD drive will
fail.
Output from HELP "MOUNT":
[38;5;11m MOUNT <> |
[39m
Lists the mounted drives or mounts a new drive.
With no arguments, prints a list of mounted drives and their targets.
With two arguments, mounts the drive_name$ to point to the target$.
Drive names are specified without a colon at the end, and targets are
given in the form of a URI.
Output from HELP "NEW":
[38;5;11m NEW
[39m
Restores initial machine state and creates a new program.
This command resets the machine to a pristine state by clearing all
user-defined variables and restoring the state of shared resources.
These resources include: the console, whose color and video syncing bit
are reset; and the GPIO pins, which are set to their default state.
The stored program is also discarded from memory, but NEW will pause to
ask before discarding any unsaved modifications. To reset resources
but avoid clearing the stored program, use CLEAR instead.
Output from HELP "PRINT":
[38;5;11m PRINT [expr1 <,|;> .. <,|;> exprN]
[39m
Prints one or more values to the console.
The expressions given as arguments are all evaluated and converted to
strings before they are printed. See the documentation of STR$() for
the conversion rules.
Using a `;` separator between arguments causes the two adjacent values
to be displayed together. For strings, this means that no space is
added between them; for all other types, a space is added after the
value on the left side.
Using a `,` separator between arguments works the same as `;` except
that the fields are left-aligned to 14-character wide fields on the
screen.
If the last expression is empty (i.e. if the statement ends in a
semicolon or a comma), then the cursor position remains on the same
line of the message right after what was printed.
Output from HELP "PWD":
[38;5;11m PWD
[39m
Prints the current working location.
If the EndBASIC path representing the current location is backed by a
real path that is accessible by the underlying operating system,
displays such path as well.
Output from HELP "RAD":
[38;5;11m RAD
[39m
Sets radians mode of calculation.
The default condition for the trigonometric functions is to use radians
but it can be set to degrees with the DEG command. RAD restores the
environment to use radians mode.
Output from HELP "RANDOMIZE":
[38;5;11m RANDOMIZE <> |
[39m
Reinitializes the pseudo-random number generator.
If no seed is given, uses system entropy to create a new sequence of
random numbers.
WARNING: These random numbers offer no cryptographic guarantees.
Output from HELP "READ":
[38;5;11m READ vref1[, .., vrefN]
[39m
Extracts data values from DATA statements.
DATA statements can appear anywhere in the program and they register
data values into an array of values. READ is then used to extract
values from this array into the provided variables in the order in
which they were defined. In other words: READ maintains an internal
index into the data array that gets incremented by the number of
provided variables every time it is executed.
The variable references in the vref1..vrefN list must match the types
or be compatible with the values in the corresponding position of the
data array. Empty values in the data array can be specified by DATA,
and those are converted into the default values for the relevant types:
booleans are false, numbers are 0, and strings are empty.
Attempting to extract more values than are defined by DATA results in
an "out of data" error.
The index that READ uses to extract DATA values can be reset by RESTORE
and, more generally, by CLEAR.
Output from HELP "RESTORE":
[38;5;11m RESTORE
[39m
Resets the index of the data element to be returned.
This allows READ to re-return the same elements that were previously
extracted from the array of values defined by DATA.
Output from HELP "RUN":
[38;5;11m RUN
[39m
Runs the stored program.
This issues a CLEAR operation before starting the program to prevent
previous leftover state from interfering with the new execution.
Output from HELP "SAVE":
[38;5;11m SAVE <> |
[39m
Saves the current program in memory to the given filename.
The filename must be a string and must be a valid EndBASIC path. The
.BAS extension is optional but, if present, it must be .BAS.
If no filename is given, SAVE will try to use the filename of the
loaded program (if any) and will fail if no name has been given yet.
See the "File system" help topic for information on the path syntax.
Output from HELP "SHARE":
[38;5;11m SHARE filename$[, acl1$, .., aclN$]
[39m
Displays or modifies the ACLs of a file.
If given only a filename$, this command prints out the ACLs of the
file.
Otherwise, when given a list of ACL changes, applies those changes to
the file. The acl1$ to aclN$ arguments are strings of the form
"username+r" or "username-r", where the former adds "username" to the
users allowed to read the file, and the latter removes "username" from
the list of users allowed to read the file.
You can use the special "public+r" ACL to share a file with everyone.
These files can be auto-run via the web interface using the special URL
that the command prints on success.
Note that this command only works for cloud-based drives as it is
designed to share files among users of the EndBASIC service.
Output from HELP "SIGNUP":
[38;5;11m SIGNUP
[39m
Creates a new user account interactively.
This command will ask you for your personal information to create an
account in the EndBASIC cloud service. You will be asked for
confirmation before proceeding.
Output from HELP "SLEEP":
[38;5;11m SLEEP seconds#
[39m
Suspends program execution.
Pauses program execution for the given number of seconds, which can be
specified either as an integer or as a floating point number for finer
precision.
Output from HELP "UNMOUNT":
[38;5;11m UNMOUNT drive_name$
[39m
Unmounts the given drive.
Drive names are specified without a colon at the end.
Output from HELP "ASC":
[38;5;11m ASC%(char$)
[39m
Returns the UTF character code of the input character.
The input char$ argument is a string that must be 1-character long.
This is called ASC for historical reasons but supports more than just
ASCII characters in this implementation of BASIC.
See CHR$() for the inverse of this function.
Output from HELP "ATN":
[38;5;11m ATN#(n#)
[39m
Computes the arc-tangent of a number.
The resulting angle is measured in degrees or radians depending on the
angle mode as selected by the DEG and RAD commands.
Output from HELP "CHR":
[38;5;11m CHR$(code%)
[39m
Returns the UTF character that corresponds to the given code.
See ASC%() for the inverse of this function.
Output from HELP "CINT":
[38;5;11m CINT%(expr#)
[39m
Casts the given numeric expression to an integer (with rounding).
When casting a double value to an integer, the double value is first
rounded to the closest integer. For example, 4.4 becomes 4, but both
4.5 and 4.6 become 5.
Output from HELP "COS":
[38;5;11m COS#(angle#)
[39m
Computes the cosine of an angle.
The input angle% or angle# is measured in degrees or radians depending
on the angle mode as selected by the DEG and RAD commands.
Output from HELP "ERRMSG":
[38;5;11m ERRMSG$
[39m
Returns the last captured error message.
When used in combination of ON ERROR to set an error handler, this
function returns the string representation of the last captured error.
If this is called before any error is captured, returns the empty
string.
Output from HELP "GFX_HEIGHT":
[38;5;11m GFX_HEIGHT%
[39m
Returns the height in pixels of the graphical console.
See GFX_WIDTH to query the other dimension.
Output from HELP "GFX_WIDTH":
[38;5;11m GFX_WIDTH%
[39m
Returns the width in pixels of the graphical console.
See GFX_HEIGHT to query the other dimension.
Output from HELP "GPIO_READ":
[38;5;11m GPIO_READ?(pin%)
[39m
Reads the state of a GPIO pin.
Returns FALSE to represent a low value, and TRUE to represent a high
value.
Output from HELP "INKEY":
[38;5;11m INKEY$
[39m
Checks for an available key press and returns it.
If a key press is available to be read, returns its name. Otherwise,
returns the empty string. The returned key matches its name, number,
or symbol and maintains case. In other words, pressing the X key will
return 'x' or 'X' depending on the SHIFT modifier.
The following special keys are recognized: arrow keys (UP, DOWN, LEFT,
RIGHT), backspace (BS), end or CTRL+E (END), enter (ENTER), CTRL+D
(EOF), escape (ESC), home or CTRL+A (HOME), CTRL+C (INT), page up
(PGUP), page down (PGDOWN), and tab (TAB).
This function never blocks. To wait for a key press, you need to
explicitly poll the keyboard. For example, to wait until the escape
key is pressed, you could do:
k$ = "": WHILE k$ <> "ESC": k = INKEY$: SLEEP 0.01: WEND
This non-blocking design lets you to combine the reception of multiple
evens, such as from GPIO_INPUT?, within the same loop.
Output from HELP "INT%":
[38;5;11m INT%(expr#)
[39m
Casts the given numeric expression to an integer (with truncation).
When casting a double value to an integer, the double value is first
truncated to the smallest
integer that is not larger than the double value. For example, all of
4.4, 4.5 and 4.6 become 4.
Output from HELP "LBOUND":
[38;5;11m LBOUND%( | )
[39m
Returns the lower bound for the given dimension of the array.
The lower bound is the smallest available subscript that can be
provided to array indexing operations.
For one-dimensional arrays, the dimension% is optional. For
multi-dimensional arrays, the dimension% is a 1-indexed integer.
Output from HELP "LEFT":
[38;5;11m LEFT$(expr$, n%)
[39m
Returns a given number of characters from the left side of a string.
If n% is 0, returns an empty string.
If n% is greater than or equal to the number of characters in expr$,
returns expr$.
Output from HELP "LEN":
[38;5;11m LEN%(expr$)
[39m
Returns the length of the string in expr$.
Output from HELP "LTRIM":
[38;5;11m LTRIM$(expr$)
[39m
Returns a copy of a string with leading whitespace removed.
Output from HELP "MAX":
[38;5;11m MAX#(expr1#[, .., exprN#])
[39m
Returns the maximum number out of a set of numbers.
Output from HELP "MID":
[38;5;11m MID$( | )
[39m
Returns a portion of a string.
start% indicates the starting position of the substring to extract and
it is 1-indexed.
length% indicates the number of characters to extract and, if not
specified, defaults to extracting
until the end of the string.
Output from HELP "MIN":
[38;5;11m MIN#(expr1#[, .., exprN#])
[39m
Returns the minimum number out of a set of numbers.
Output from HELP "PI":
[38;5;11m PI#
[39m
Returns the Archimedes' constant.
Output from HELP "RIGHT":
[38;5;11m RIGHT$(expr$, n%)
[39m
Returns a given number of characters from the right side of a string.
If n% is 0, returns an empty string.
If n% is greater than or equal to the number of characters in expr$,
returns expr$.
Output from HELP "RND":
[38;5;11m RND#(<> | )
[39m
Returns a random number in the [0..1] range.
If n% is zero, returns the previously generated random number. If n%
is positive or is not specified, returns a new random number.
If you need to generate an integer random number within a specific
range, say [0..100], compute it with an expression like CINT%(RND#(1) *
100.0).
WARNING: These random numbers offer no cryptographic guarantees.
Output from HELP "RTRIM":
[38;5;11m RTRIM$(expr$)
[39m
Returns a copy of a string with trailing whitespace removed.
Output from HELP "SCRCOLS":
[38;5;11m SCRCOLS%
[39m
Returns the number of columns in the text console.
See SCRROWS to query the other dimension.
Output from HELP "SCRROWS":
[38;5;11m SCRROWS%
[39m
Returns the number of rows in the text console.
See SCRCOLS to query the other dimension.
Output from HELP "SIN":
[38;5;11m SIN#(angle#)
[39m
Computes the sine of an angle.
The input angle% or angle# is measured in degrees or radians depending
on the angle mode as selected by the DEG and RAD commands.
Output from HELP "SQR":
[38;5;11m SQR#(num#)
[39m
Computes the square root of the given number.
Output from HELP "STR$":
[38;5;11m STR$(expr)
[39m
Formats a scalar value as a string.
If expr evaluates to a string, this returns the string unmodified.
If expr evaluates to a boolean, this returns the strings FALSE or TRUE.
If expr evaluates to a number, this returns a string with the textual
representation of the number. If the number does NOT have a negative
sign, the resulting string has a single space in front of it.
To obtain a clean representation of expr as a string without any
artificial whitespace characters in it, do LTRIM$(STR$(expr)).
Output from HELP "TAN":
[38;5;11m TAN#(angle#)
[39m
Computes the tangent of an angle.
The input angle% or angle# is measured in degrees or radians depending
on the angle mode as selected by the DEG and RAD commands.
Output from HELP "UBOUND":
[38;5;11m UBOUND%( | )
[39m
Returns the upper bound for the given dimension of the array.
The upper bound is the largest available subscript that can be provided
to array indexing operations.
For one-dimensional arrays, the dimension% is optional. For
multi-dimensional arrays, the dimension% is a 1-indexed integer.