To simulate the occurrence of an error, or to allow the user to define error codes.
ERROR integer expression
The value of integer expression must be greater than 0 and less than 255.
If the value of integer expression equals an error code already in use by GW-BASIC, the ERROR statement simulates the occurrence of that error, and the corresponding error message is printed.
A user-defined error code must use a value greater than any used by the GW- BASIC error codes. There are 76 GW-BASIC error codes at present. It is preferable to use a code number high enough to remain valid when more error codes are added to GW-BASIC.
User-defined error codes may be used in an error-trapping routine.
If an ERROR statement specifies a code for which no error message has been defined, GW-BASIC responds with the message "Unprintable Error".
Execution of an ERROR statement for which there is no error-trapping routine causes an error message to be printed and execution to halt.
The following examples simulate error 15 (the code for "String too long"):
30 ERROR S+T
String too long in 30
Or, in direct mode:
ERROR 15 (you type this line)
String too long (GW-BASIC types this line)
The following example includes a user-defined error code message.
110 ON ERROR GOTO 400
120 INPUT "WHAT IS YOUR BET";B
130 IF B>5000 THEN ERROR 210
400 IF ERR=210 THEN PRINT "HOUSE LIMIT IS $5000"
410 IF ERL=130 THEN RESUME 120
All Frank Sinatra recordings, All Beatles albums, All solo albums from John Lennon, Paul McCartney, George Harrison and Ringo Starr, All Beatles songs, List of Platinum selling albums, Database with hits from 1950 to 1999.
Sought after DLL files, Nutworks magazine (retro), Worldwide ISO and TLD codes, File extensions database, The Hackers dictionary, Free software for the Atari, Amiga and Macintosh, Nokia smartphone, PocketPC, List of all BASIC programming language commands, List of all DOS commands, Free Advanced Bash-Scripting Guide (Linux-Unix)