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
RESUMERES{Shift+U}D63.5, 7.0Statement
DLOADD{Shift+L}  D6 4.x Command and Statement* 
RESUMERES{Shift+U}E34.xStatement
GSHAPEG{Shift+S} E3 3.5, 7.0 Command and Statement 

 
Syntax 
RESUME [ { lineNumber | NEXT } ]
 
ParametersTypeLegal Value(s)Default ValueNote(s)
lineNumberUnsigned Integer0 ~ 63999If used, the program line must exist and it must be a literal number.
 
 
 
Purpose 
Program error control; exit an error trap routine and re-enable error traps in a program.

 
 
Remarks 
RESUME allows three ways to exit an error trap routine (see TRAP).  Without any parameter, BASIC will exit to the same statement that caused the error.  Unless the error trap routine changed a variable used by that statment, that statement will very likely cause the error trap routine to be immediately called again (i.e., an infinite loop).  With the NEXT keyword as the parameter, BASIC will exit to the statement following the one that caused the error.  This is often used.  The final option is to give a specific lineNumber where the program should continue executing.
 
If RESUME is used in direct mode, an ILLEGAL DIRECT ERROR is generated.  If RESUME is used in a program without an error having occurred (i.e., not in a trap routine) then CAN'T RESUME ERROR (or UNABLE TO RESUME ERROR) is generated.
 
Now lets assume an error has occured and called the error trap routine.  Once RESUME is used, error-trapping is re-enabled (it is temporarily disabled when the trap routine is called) unless the trap routine issued TRAP without any lineNumber (which disables error-trapping).
 
If you are having trouble with RESUME (no argument) and RESUME NEXT, then one thing you can try is to use HELP in your trap routine.  This will not only list the line that caused the error (which you should know from variable EL), but also highlights the statement which cause the error.  This is the statement that will be re-executed when RESUME (no argument) is used.  The statement following the highlighted the colon (:) or, if that does not exist the first statement of the next line, is the one that will be executed with RESUME NEXT.
 
Assuming lineNumber is given, it must be a literal line number, like GOTO/GOSUB (but unlike TRAP), or SYNTAX ERROR is generated.  If the lineNumber is not a legal value (see above), an ILLEGAL QUANTITY ERROR is generated.  Any of these errors (like any other error that occurs in the trap routine) will cause BASIC to switch to direct mode (abort the program) and print an error message.  Otherwise, the lineNumber must exist or an UNDEF'D STATMENT ERROR is generated, but unlike any of the other errors, BASIC will not exit to immediate mode and print an error, but instead the TRAP routine will immediately be called again, which usually results in an infinite loop.  This occurs because BASIC re-enables error traps after it evaluates the lineNumber but before it tries to GOTO the lineNumber... sounds like a bug to me!
 
If a lineNumber is given, it should usually be very close to where the error occured, to avoid corruption of the BASIC stack which occurs from skipping LOOP, NEXT, and RETURN statements.  BASIC 4.x (only) has the DISPOSE keyword which can be used to remove entries from the stack.
 
The RESUME statement, no matter what parameter is used (if any) removes the "GOSUB" entry that was put on the stack when the error trap was called.  This makes it almost the same as RETURN, except of course you can specify a lineNumber with RESUME (which makes it into some kind of hybrid RETURN+GOTO statement).
 
Example:
NEW

READY.
10 TRAP 100
20 INPUT "RECTANGULAR X,Y"; X,Y
30 PRINT "POLAR M,A";
40 PRINT SQR(X*X + Y*Y) ",";
50 A = 180/p * ATN(Y/X)
60 PRINT A : PRINT
70 END
100 IF EL <> 50 THEN PRINT "UNEXPECTED" : STOP
110 A = 90*SGN(Y)
120 RESUME NEXT : REM RESUME on line 60
RUN
RECTANGULAR X,Y? 0,4 (user input)
POLAR M,A 4, 90                  note BASIC called the trap routine (not obvious)

READY.
120 PRINT : RESUME 20 : REM Start over
RUN
RECTANGULAR X,Y? 0,4 (user input)
POLAR M,A 4,                     note BASIC called the trap routine...
RECTANGULAR X,Y?                 ...and started over
 
 
 
Compare With 
 
 
Contrast With 
 
See Also 
EL, ER, ERR$, HELPNEXTTRAP
© H2Obsession, 2014