Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I can't get RETURN TO to work right.
Message
De
03/07/2002 14:27:52
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
I can't get RETURN TO to work right.
Divers
Thread ID:
00675050
Message ID:
00675050
Vues:
45
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform