Original Author Paul Laughton, 2011
Page 64
De Re BASIC!
An error that stops your program writes an error message to the Console. If you trap the error with the
OnError: interrupt label, your program does not stop and the error is not printed. You can use
GETERROR$() to retrieve the error message.
Certain commands can report errors without stopping your program. These commands include
App.broadcast, App.start, Audio.load, Byte.open, Text.open, Zip.Open, Encrypt, Decrypt, Font.load,
GPS.open, GrabFile, GrabURL, Gr.get.type, the ENCODE$() and DECODE$() functions, and any command
that can create a bitmap.
When you run one of these commands, you can call GETERROR$() to retrieve information about the
error state. For example, if Text.open cannot open a file, it sets the file pointer to -1, and writes a
GETERROR$() message such as "<filename> not found". If no error occurred, GETERROR$() returns the
string "No error".
Because there are commands that clear the error message, you should not expect GETERROR$() to
retain its message. Capture the message in a variable as soon as possible, and do not call GETERROR$()
again for the same error.
CHR$(<nexp>, ...)
Return the character string represented by the values of list of numerical expressions. Each <nexp> is
converted to a character. The expressions may have values greater than 255 and thus can be used to
generate Unicode characters.
PRINT CHR$(16*4 + 3)
% Hexadecimal 43 is the character "C". This prints: C
PRINT CHR$(945, 946)
% Decimal for the characters alpha and beta: Prints:
LEFT$(<sexp>, <count_nexp>)
Return the left-most characters of the string <sexp>. The number of characters to return is set by the
count parameter, <count_nexp>.
If the count is greater than 0, return <count_nexp> characters, counting from the left.
If the count is less than 0, return all but <count_nexp> characters. The number to return is the
string length reduced by <count_nexp>: LEFT$(a$, -2) is the same as LEFT$(a$, LEN(a$) - 2).
If the count is 0, return an empty string ("").
If the count is greater than the length of the string, return the entire string.
MID$(<sexp>, <start_nexp>{, <count_nexp>})
Return a substring of the string <sexp>, beginning or ending at the start position <start_nexp>. The first
character of the string is at position 1. If the start position is 0 or negative, it is set to 1.
The count parameter is optional. If it is omitted, return all of the characters from the start position to
the end of the string.
a$ = MID$("dinner", 2)
% a$ is "inner"