Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (divide)
      (equal)
      (less)
      (minus)
      (more)
      (multiply)
      (plus)
      (power)
      Abs
      And
      Append
      Asc
      Atn
      Auto
      Backup
      Bank
      Begin
      Bend
      Bload
      Boot
      Box
      Bsave
      Bump
      Catalog
      Char
      Chr
      Circle
      Close
      Clr
      Cmd
      Collect
      Collision
      Color
      Concat
      Cont
      Copy
      Cos
      Data
      Dclear
      Dclose
      Dec
      Def
      Delete
      Dim
      Directory
      Dispose
      Dload
      Do
      Dopen
      Draw
      Ds
      Ds string
      Dsave
      Dverify
      El
      Else
      End
      Envelope
      Er
      Err
      Exit
      Exp
      Fast
      Fetch
      Filter
      Fn
      For
      Fre
      Get
      Get num
      Getkey
      Go
      Gosub
      Goto
      Graphic
      Gshape
      Header
      Help
      Hex
      If
      Input
      Input num
      Instr
      Int
      Joy
      Key
      Left
      Len
      Let
      List
      Load
      Locate
      Log
      Loop
      Mid
      Monitor
      Movspr
      New
      Next
      Not
      Off
      On
      Open
      Or
      Paint
      Peek
      Pen
      Pi
      Play
      Pointer
      Poke
      Pos
      Pot
      Print
      Print num
      Pudef
      Quit
      Rclr
      Rdot
      Read
      Record
      Rem
      Rename
      Renumber
      Restore
      Resume
      Return
      Rgr
      Right
      Rlum
      Rnd
      Rreg
      Rspcolor
      Rsppos
      Rsprite
      Run
      Rwindow
      Save
      Scale
      Scnclr
      Scratch
      Sgn
      Sin
      Sleep
      Slow
      Sound
      Spc
      Sprcolor
      Sprdef
      Sprite
      Sprsav
      Sqr
      Sshape
      St
      Stash
      Step
      Stop
      Str
      Swap
      Sys
      Tab
      Tan
      Tempo
      Then
      Ti
      Ti string
      To
      Trap
      Troff
      Tron
      Until
      Using
      Usr
      Val
      Verify
      Vol
      Wait
      While
      Width
      Window
      Xor
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
KeywordAbbreviationToken (hex)Version(s)Classification
ERR$E{Shift+R}D33.5, 7.0Function
COPYCO{Shift+P}D34.xCommand and Statement
ERR$E{Shift+R}E74.7Function
COLORvariesE73.5, 7.0Command and Statement

 Syntax 
ERR$ errorNumber )
 
ParametersTypeLegal Value(s)Note(s)
errorNumberInteger
varies
 
ReturnsTypeValue(s)Note(s)
errorMessageString
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.
errorNumbererrorMessageVersion(s)Note(s)
1TOO MANY FILES
3.5+
the min value for v3.5 and v7.0
2FILE OPEN
3.5+
 
3FILE NOT OPEN
3.5+
 
4FILE NOT FOUND
3.5+
 
5DEVICE NOT PRESENT
3.5+
 
6NOT INPUT FILE
3.5+
 
7NOT OUTPUT FILE
3.5+
 
8MISSING FILE NAME
3.5+
 
9ILLEGAL DEVICE NUMBER
3.5+
 
 
Now a list of error messages for versions 3.5 and 7.0:
errorNumbererrorMessageVersion(s)Note(s)
10NEXT WITHOUT FOR
3.5, 7.0
 
11SYNTAX
3.5, 7.0
12RETURN WITHOUT GOSUB
3.5, 7.0
 
13OUT OF DATA
3.5, 7.0
 
14ILLEGAL QUANTITY
3.5, 7.0
 
15OVERFLOW
3.5, 7.0
 
16OUT OF MEMORY
3.5, 7.0
 
17UNDEF'D STATEMENT
3.5, 7.0
 
18BAD SUBSCRIPT
3.5, 7.0
 
19REDIM'D ARRAY
3.5, 7.0
 
20DIVISION BY ZERO
3.5, 7.0
 
21ILLEGAL DIRECT
3.5, 7.0
22TYPE MISMATCH
3.5, 7.0
 
23STRING TOO LONG
3.5, 7.0
 
24FILE DATA
3.5, 7.0
 
25FORMULA TOO COMPLEX
3.5, 7.0
 
26CAN'T CONTINUE
3.5, 7.0
 
27UNDEF'D FUNCTION
3.5, 7.0
 
28VERIFY
3.5, 7.0
 
29LOAD
3.5, 7.0
 
30BREAK
3.5, 7.0
 
31CAN'T RESUME
3.5, 7.0
32LOOP NOT FOUND
3.5, 7.0
 
33LOOP WITHOUT DO
3.5, 7.0
 
34DIRECT MODE ONLY
3.5, 7.0
 
35NO GRAPHICS AREA
3.5, 7.0
 
36BAD DISK
3.5, 7.0
the max for version 3.5 
37BEND NOT FOUND
7.0
 
38LINE NUMBER TOO LARGE
7.0
 
39UNRESOLVED REFERENCE
7.0
 
40UNIMPLEMENTED COMMAND 7.0  
41FILE READ 7.0 the max for version 7.0 
 
Finally a list of error messages specific to version 4.x:
errorNumbererrorMessageVersion(s)Note(s)
0STOP KEY DETECTED 4.xthe min for 4.x
10ARE YOU SURE ?4.xnot trappable
11BAD DISK4.x
12READY.4.xnot trappable 
13 IN4.xnot trappable
14BREAK4.x
15EXTRA IGNORED4.xnot trappable 
16REDO FROM START4.xnot trappable
17 174.x?
18MORE4.xnot trappable
19♥*** COMMODORE BASIC 128, V4.0 ***4.xnot trappable
20NEXT WITHOUT FOR4.x
21SYNTAX4.x
22RETURN WITHOUT GOSUB4.x 
23OUT OF DATA4.x 
24ILLEGAL QUANTITY4.x 
25OVERFLOW4.x 
26OUT OF MEMORY4.x 
27UNDEF'D STATEMENT4.x 
28BAD SUBSCRIPT4.x 
29REDIM'D ARRAY4.x 
30DIVISION BY ZERO4.x 
31ILLEGAL DIRECT4.x
32TYPE MISMATCH4.x 
33STRING TOO LONG4.x 
34FILE DATA4.x 
35FORMULA TOO COMPLEX4.x 
36CANNOT CONTINUE4.x 
37UNDEF'D FUNCTION4.x 
38?LOAD ERROR4.x 
39?VERIFY ERROR4.x 
40OUT OF STACK 4.xnot trappable 
41UNABLE TO RESUME4.xmay not trappable
42UNABLE TO DISPOSE4.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:
errorMessagev3.5
errorNumber
v4.x
errorNumber
v7.0
errorNumber
Note(s)
BAD DISK113611 
BAD SUBSCRIPT182818 
BEND NOT FOUND  37 
BREAK301430 
CAN'T CONTINUE263626in 4.x: CANNOT CONTINUE
CAN'T RESUME314131in 4.x: UNABLE TO RESUME
DEVICE NOT PRESENT555 
DIRECT MODE ONLY34 34 
DIVISION BY ZERO203020 
EXTRA IGNORED15this error is possible in all versions; TRAP-able in none 
FILE DATA243424 
FILE NOT FOUND444 
FILE NOT OPEN333 
FILE OPEN222 
FILE READ  41 
FORMULA TOO COMPLEX253525 
ILLEGAL DEVICE NUMBER999 
ILLEGAL DIRECT213121 
ILLEGAL QUANTITY142414 
LINE NUMBER TOO LARGE  38 
LOAD293829in 4.x: ?LOAD ERROR
LOOP NOT FOUND32 32 
LOOP WITHOUT DO33 33 
MISSING FILE NAME888 
NEXT WITHOUT FOR102010 
NO GRAPHICS AREA35 35 
NOT INPUT FILE666 
NOT OUTPUT FILE777 
OUT OF DATA132313 
OUT OF MEMORY162616 
OUT OF STACK  40 corresponds with OUT OF MEMORY (16) in other versions
OVERFLOW152515 
REDIM'D ARRAY192919 
REDO FROM START16this error is possible in all versions; TRAP-able in none
RETURN WITHOUT GOSUB122212 
STOP KEY DETECTED0corresponds with BREAK (30) in other versions 
STRING TOO LONG233323 
SYNTAX112111 
TOO MANY FILES111 
TYPE MISMATCH223222 
UNABLE TO DISPOSE 42  
UNABLE TO RESUME314131in 3.5,7.0: CAN'T RESUME
UNDEF'D FUNCTION273727 
UNDEF'D STATEMENT172717 
UNIMPLEMENTED COMMAND   40 
UNRESOLVED REFERENCE  39 
VERIFY283928in 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