Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I can't get RETURN TO to work right.
Message
From
03/07/2002 14:27:52
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
I can't get RETURN TO to work right.
Miscellaneous
Thread ID:
00675050
Message ID:
00675050
Views:
46
I'm using VFP7SP1.

I'm finally starting to put code in my ERROR method for classes, instead of letting my global error handler just shut down the app.

I can't get "Return to myMethod" to work.
DEFINE CLASS cusPAYROLL as CUSTOM
  cMethodToReturnTo = ''

  PROCEDURE myMethod
    THIS.cMethodToReturnTo = PROGRAM()
    THIS.pck_Records()
    RETURN THIS.lError
  ENDPROC

  PROCEDURE pck_Records()
    ..... processing
    ERROR 5                                   << works fine
    ..... processing
  ENDPROC

  PROCEDURE ERROR()
    LPARAMETERS nError, cMethod, nLine
  
    LOCAL lcError, llJustLogError, lcReturn
    WITH THIS
      .lError = .T.
      ***** determine which method the error occured in
      DO CASE
        CASE ATC( 'pck_Records', cMethod )>0
          llJustLogError = .T.
        CASE ATC( 'csCount', cMethod )>0
          llJustLogError = .T.
        OTHERWISE
          ***** Unanticipated error occured 
          llJustLogError = .F.
      ENDCASE
      lcError = ON('Error')
      IF llJustLogError 
        ***** triggers Errorhandler to RETURN rather than QUIT
        lcError = lcError + [, .T.]
      ENDIF
      lcError = STRTRAN( lcError , 'PROGRAM()', ['] + .NAME + '.' + cMethod + ['] )
      lcError = STRTRAN( lcError , 'LINENO()', TRANSFORM(nLine) )
      lcError = STRTRAN( lcError , 'ERROR()', TRANSFORM(nError) )
      &lcError 
      lcReturn = "RETURN TO " + .cMethodToReturnTo
      &lcReturn                                        
    ENDWITH
  ENDPROC
ENDDEFINE
&lcReturn
In Real Time - crashes with "Syntax Error"
In Debugger - ignored and returns to method where error occured and continues to process


TIA
Bill Morris
Next
Reply
Map
View

Click here to load this message in the networking platform