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
ERnone45 523.5, 4.7+Reserved variable
Note the 'token' is really the character codes of the keyword.

 Syntax 
ER
 
ReturnsTypeValue(s)Note(s)
errorNumberInteger
varies
 
 
 Purpose 
Error trapping (and debugging); return the most recent errorNumber.
 
 Remarks 
This returns the most recent errorNumber.  In BASIC versions 3.5 and 7.0, a value of -1 indicates no previous error.  In version 4.7 a value of 127 indicates no previous error.  Assuming there was a last error, a string description corresponding to the errorNumber may be obtained with ERR$; see that function for a list of errorNumbers and error messages (these vary by version number, sometimes drastically).
 
The value is set to "no error" on power-up and whenever CLR is executed (performed as a part of RUN and, in direct mode, (D)LOAD).  The value is also (usually) set when an error occurs.  Exceptions are the special (untrappable) errors of INPUT: EXTRA IGNORED and REDO FROM START.
 
ER is typically used in a program's TRAP handler to determine what kind of error occured.  Because the line number of the error is also available (see EL), the ER value may not be needed (i.e., the error can be inferred by the programmer based on which line has the error).  It may occassionaly be useful in direct mode while debugging in order to recall the last error (for example if a displayed error message scrolls off the screen while listing program lines).
 
Like all BASIC variables, only the first two characters of the name are significant.  So you may also append extra characters; you could use the name ERRNUM if you prefer (note the -RNUM would be superfluous).
 
Like most reserved variables, a SYNTAX ERROR will be generated if you attempt to assign a value to ER.
 
In version 4.7, ER is only valid in a program.  In direct mode it returns 127 (no error).
 
Examples (version 3.5 and 7.0):
PRINT ER
-1

READY.
JUMP OF A CLIFF
?SYNTAX ERROR

READY.
PRINT ER
 11

READY.

 Compare With 
 
 See Also 

© H2Obsession, 2014