Home

# ERROR Statement

#### Purpose:

To simulate the occurrence of an error, or to allow the user to define error codes.

#### Syntax:

`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.

For a complete list of the error codes and messages already defined in GW-BASIC, refer to Appendix A in the GW-BASIC User's Guide.

#### Examples:

The following examples simulate error 15 (the code for "String too long"):

```10 S=10
20 T=5
30 ERROR S+T
40 END
RUN
Ā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
.
.
.```
{"ft_lang_label":"__label__en","ft_lang_prob":0.7504723,"math_prob":0.54050887,"size":1577,"snap":"2021-31-2021-39","text_gpt3_token_len":377,"char_repetition_ratio":0.14939606,"word_repetition_ratio":0.0,"special_character_ratio":0.25808498,"punctuation_ratio":0.09006211,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95080644,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-05T13:23:10Z\",\"WARC-Record-ID\":\"<urn:uuid:cb530899-71f7-4e0b-95d0-b8b787658b7e>\",\"Content-Length\":\"2845\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:87516bc4-2eae-416c-a28e-f9829be3865a>\",\"WARC-Concurrent-To\":\"<urn:uuid:91d2f5aa-7d8a-48a0-b337-535409726b31>\",\"WARC-IP-Address\":\"67.207.81.229\",\"WARC-Target-URI\":\"https://gw-basic.netlify.app/files/tuts/gw-man/error\",\"WARC-Payload-Digest\":\"sha1:75IMXW74P77USCNQDTBIVSIKRVYGJMVU\",\"WARC-Block-Digest\":\"sha1:ORUWKNGDB22RNL73N26YYP3ZQRIY2ZDN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046155925.8_warc_CC-MAIN-20210805130514-20210805160514-00097.warc.gz\"}"}