Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

ERR$

Keyword Abbreviation Token (hex) Version(s) Classification
ERR$ E{Shift+R} D3 3.5, 7.0 Function
COPY CO{Shift+P} D3 4.x Command and Statement
ERR$ E{Shift+R} E7 4.7 Function
COLOR varies E7 3.5, 7.0 Command and Statement

  Syntax  
ERR$ errorNumber )
 
Parameters Type Legal Value(s) Note(s)
errorNumber Integer
varies
 
Returns Type Value(s) Note(s)
errorMessage String
varies
 
 
  Purpose  
Return the error message corresponding to an error number.

 
  Remarks  
The ERR$ function returns a string description of a corresponding errorNumber.  Because the errorMessages are fixed in ROM, this is more like an array than a function.  Anyway, it is useful for debugging or error trapping.  The last errorNumber is available from reserved variable ER.
 
If errorNumber is omitted, or is an invalid expression, SYNTAX ERROR occurs.  If errorNumber is not numeric, TYPE MISMATCH ERROR occurs.  A floating-point value will (effectively) be converted with INT.  If errorNumber is less than min or greater than max (see below) then ILLEGAL QUANTITY ERROR is generated, except in BASIC 4.7 where errorNumber = + 128 is also valid if x is valid (if that's not a bug, I don't know what is).  Also in BASIC v4.7, some "errors" are infromational messages or questions, decide for yourself if that is a bug.
 
Many, but not all of the error messages are compatible between versions.  First a list of the common/compatible values.
errorNumber errorMessage Version(s) Note(s)
1 TOO MANY FILES
3.5+
the min value for v3.5 and v7.0
2 FILE OPEN
3.5+
 
3 FILE NOT OPEN
3.5+
 
4 FILE NOT FOUND
3.5+
 
5 DEVICE NOT PRESENT
3.5+
 
6 NOT INPUT FILE
3.5+
 
7 NOT OUTPUT FILE
3.5+
 
8 MISSING FILE NAME
3.5+
 
9 ILLEGAL DEVICE NUMBER
3.5+
 
 
Now a list of error messages for versions 3.5 and 7.0:
errorNumber errorMessage Version(s) Note(s)
10 NEXT WITHOUT FOR
3.5, 7.0
 
11 SYNTAX
3.5, 7.0
12 RETURN WITHOUT GOSUB
3.5, 7.0
 
13 OUT OF DATA
3.5, 7.0
 
14 ILLEGAL QUANTITY
3.5, 7.0
 
15 OVERFLOW
3.5, 7.0
 
16 OUT OF MEMORY
3.5, 7.0
 
17 UNDEF'D STATEMENT
3.5, 7.0
 
18 BAD SUBSCRIPT
3.5, 7.0
 
19 REDIM'D ARRAY
3.5, 7.0
 
20 DIVISION BY ZERO
3.5, 7.0
 
21 ILLEGAL DIRECT
3.5, 7.0
22 TYPE MISMATCH
3.5, 7.0
 
23 STRING TOO LONG
3.5, 7.0
 
24 FILE DATA
3.5, 7.0
 
25 FORMULA TOO COMPLEX
3.5, 7.0
 
26 CAN'T CONTINUE
3.5, 7.0
 
27 UNDEF'D FUNCTION
3.5, 7.0
 
28 VERIFY
3.5, 7.0
 
29 LOAD
3.5, 7.0
 
30 BREAK
3.5, 7.0
 
31 CAN'T RESUME
3.5, 7.0
32 LOOP NOT FOUND
3.5, 7.0
 
33 LOOP WITHOUT DO
3.5, 7.0
 
34 DIRECT MODE ONLY
3.5, 7.0
 
35 NO GRAPHICS AREA
3.5, 7.0
 
36 BAD DISK
3.5, 7.0
the max for version 3.5 
37 BEND NOT FOUND
7.0
 
38 LINE NUMBER TOO LARGE
7.0
 
39 UNRESOLVED REFERENCE
7.0
 
40 UNIMPLEMENTED COMMAND  7.0   
41 FILE READ  7.0  the max for version 7.0 
 
Finally a list of error messages specific to version 4.x:
errorNumber errorMessage Version(s) Note(s)
0 STOP KEY DETECTED  4.x the min for 4.x
10 ARE YOU SURE ? 4.x not trappable
11 BAD DISK 4.x
12 READY. 4.x not trappable 
13  IN 4.x not trappable
14 BREAK 4.x
15 EXTRA IGNORED 4.x not trappable 
16 REDO FROM START 4.x not trappable
17  17 4.x ?
18 MORE 4.x not trappable
19 ♥*** COMMODORE BASIC 128, V4.0 *** 4.x not trappable
20 NEXT WITHOUT FOR 4.x
21 SYNTAX 4.x
22 RETURN WITHOUT GOSUB 4.x  
23 OUT OF DATA 4.x  
24 ILLEGAL QUANTITY 4.x  
25 OVERFLOW 4.x  
26 OUT OF MEMORY 4.x  
27 UNDEF'D STATEMENT 4.x  
28 BAD SUBSCRIPT 4.x  
29 REDIM'D ARRAY 4.x  
30 DIVISION BY ZERO 4.x  
31 ILLEGAL DIRECT 4.x
32 TYPE MISMATCH 4.x  
33 STRING TOO LONG 4.x  
34 FILE DATA 4.x  
35 FORMULA TOO COMPLEX 4.x  
36 CANNOT CONTINUE 4.x  
37 UNDEF'D FUNCTION 4.x  
38 ?LOAD ERROR 4.x  
39 ?VERIFY ERROR 4.x  
40 OUT OF STACK  4.x not trappable 
41 UNABLE TO RESUME 4.x may not trappable
42 UNABLE TO DISPOSE 4.x  the max for version 4.x  
An interesting note is that the word "ERROR" appears only in errorMessages of 38 and 39 of v4.x (does not appear at all in other versions).
 
Here is an alphabetical listing (errors only), in case you would like to compare errorNumbers among versions:
errorMessage v3.5
errorNumber
v4.x
errorNumber
v7.0
errorNumber
Note(s)
BAD DISK 11 36 11  
BAD SUBSCRIPT 18 28 18  
BEND NOT FOUND     37  
BREAK 30 14 30  
CAN'T CONTINUE 26 36 26 in 4.x: CANNOT CONTINUE
CAN'T RESUME 31 41 31 in 4.x: UNABLE TO RESUME
DEVICE NOT PRESENT 5 5 5  
DIRECT MODE ONLY 34   34  
DIVISION BY ZERO 20 30 20  
EXTRA IGNORED 15 this error is possible in all versions; TRAP-able in none 
FILE DATA 24 34 24  
FILE NOT FOUND 4 4 4  
FILE NOT OPEN 3 3 3  
FILE OPEN 2 2 2  
FILE READ     41  
FORMULA TOO COMPLEX 25 35 25  
ILLEGAL DEVICE NUMBER 9 9 9  
ILLEGAL DIRECT 21 31 21  
ILLEGAL QUANTITY 14 24 14  
LINE NUMBER TOO LARGE     38  
LOAD 29 38 29 in 4.x: ?LOAD ERROR
LOOP NOT FOUND 32   32  
LOOP WITHOUT DO 33   33  
MISSING FILE NAME 8 8 8  
NEXT WITHOUT FOR 10 20 10  
NO GRAPHICS AREA 35   35  
NOT INPUT FILE 6 6 6  
NOT OUTPUT FILE 7 7 7  
OUT OF DATA 13 23 13  
OUT OF MEMORY 16 26 16  
OUT OF STACK    40   corresponds with OUT OF MEMORY (16) in other versions
OVERFLOW 15 25 15  
REDIM'D ARRAY 19 29 19  
REDO FROM START 16 this error is possible in all versions; TRAP-able in none
RETURN WITHOUT GOSUB 12 22 12  
STOP KEY DETECTED 0 corresponds with BREAK (30) in other versions 
STRING TOO LONG 23 33 23  
SYNTAX 11 21 11  
TOO MANY FILES 1 1 1  
TYPE MISMATCH 22 32 22  
UNABLE TO DISPOSE   42    
UNABLE TO RESUME 31 41 31 in 3.5,7.0: CAN'T RESUME
UNDEF'D FUNCTION 27 37 27  
UNDEF'D STATEMENT 17 27 17  
UNIMPLEMENTED COMMAND      40  
UNRESOLVED REFERENCE     39  
VERIFY 28 39 28 in 4.x: ?VERIFY ERROR
 
An interesting observation is that many of the BASIC 4.x errorNumbers are 10+ the corresponding value of BASIC 3.5 (and 7.0) except for LOAD ERROR and VERIFY ERROR which are reversed.
  
Examples:
PRINT ERR$(1)
TOO MANY FILES

READY.
PRINT ERR$(128+1) : REM  cause an error is most versions
TOO MANY FILES

READY.
  
  Compare With  
  
  Compare With  
 
  See Also  

© H2Obsession, 2014
Comments