Announcement

Collapse
No announcement yet.

Terminal Error 3 (Return without gosub)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Terminal Error 3 (Return without gosub)

    We are having problems with RETURN after error handling.

    We have a subroutine that at attempts to open a file.
    On an error (Ie. TE 71) the user is asked if the program
    should re-try the open. If the user selects not to re-try
    or re-tries and the file is eventually opened the RETURN
    from the subroutine is no longer working.

    A terminal error 3 is now reported!

    Anyone have any suggestions.



    ------------------

  • #2
    What this means is, your program is making more RETURNs than there
    are GOSUBs. Since this appears to be related to your error handler,
    you might start by making sure your error handler uses RESUME to return
    to the proper place after handling the error. The two things to look
    for, here, are: error handlers exit with RESUME, not RETURN; and that
    the location being RESUMEd to is the right place to go.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      In case you are correctely exiting the error handler with RESUME but your subsequent RETURN is still not working, you might also check the compiler option "GOSUB preserve if errors".

      ------------------
      Davide Vecchi
      [email protected]

      Comment


      • #4
        Hi Adam,

        In addition to those excellent suggestions, you might also like to check that you are testing with _all_ four types of error testing enabled ($ERROR ALL ON), just in case you have a memory corruption caused by say, writing beyond an array boundary, which is causing an "obscure" error to occur later in the program.


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          FInding all these things is made much easier, in my experience, if
          one includes a numeric line lable down in the subroutines. That way
          you get a shorter trip to the zoo to find out which animal has the
          bad manners!

          It's espectially useful if you are using nested subroutines, and then
          doubly so when you are using CALL's to SUB's! As the programs get
          bigger and bigger you'll possibly wind up putting your core routines
          into a library. You put the next most often ones in a higher level
          one, perhaps. Then you'll use these to build upon for ordinary work.

          That done, a suggestion that Lance made was probably the most single
          valuable one for all of this stuff that I've been taught. Use the
          technique of EXIT FAR AT #####. Then use a common error handling section
          in your code to do that work. ERL and ERR aren't operationally quite
          like the normal variable we all know and love in displaying this and
          that .. As you enter the master error routine it sometime helps to
          use an equate like EERR% = ERR and VERL& = ERL to gain a little bit
          of flexibility in displaying and recalling what went wrong, even
          after RESUME work!

          It's just my opinion, but a lot of the pain in handling all of this
          mess of tracing complex nested errors in PowerBASIC is still traced
          to the problem of only handling the error throw traces on the basis
          of NUMERIC LINE LABLES.

          If we had a way to use ALL LINE LABLES in the error trapping and handling
          operations and not just the numeric ones, it would sure make life a
          lot easier in my opinion.

          Maybe we'll see that in the next incantation of PowerBASIC!


          ------------------
          Mike Luther
          [email protected]
          Mike Luther
          [email protected]

          Comment

          Working...
          X