Page 1 of 1

TRY / CATCH / END

Posted: Sat Jun 10, 2023 3:25 am
by AUGE_OHR
hi,

i have some FiveWin CODE which use TRY / CATCH / END

how can i use #xTranslate for HMG Syntax :?:

Code: Select all

         TRY
            soCn:Open()
         CATCH
            MsgAlert( "CAN NOT REOPEN" + CRLF + soCn:ConnectionString )
         END
i do NOT want to "re-write" hole CODE. i want to #xTranslate

Code: Select all

#xTranslate TRY   => BEGIN SEQENCE WITH ERRORBLOCK( { | oError | DefError( oError ) } )
#xTranslate CATCH => RECOVER oError 
how get it work ...

Re: TRY / CATCH / END

Posted: Sat Jun 10, 2023 7:46 am
by edk
Maybe like that

Code: Select all

#xcommand TRY => BEGIN SEQUENCE WITH { |oErr| Break( oErr ) }
#xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->

Re: TRY / CATCH / END

Posted: Sat Jun 10, 2023 5:27 pm
by gfilatov
AUGE_OHR wrote: Sat Jun 10, 2023 3:25 am hi,

i have some FiveWin CODE which use TRY / CATCH / END

how can i use #xTranslate for HMG Syntax :?:

Code: Select all

         TRY
            soCn:Open()
         CATCH
            MsgAlert( "CAN NOT REOPEN" + CRLF + soCn:ConnectionString )
         END
i do NOT want to "re-write" hole CODE. i want to #xTranslate

Code: Select all

#xTranslate TRY   => BEGIN SEQENCE WITH ERRORBLOCK( { | oError | DefError( oError ) } )
#xTranslate CATCH => RECOVER oError 
how get it work ...
Hi Jimmy,

Just add the following string on top of your source:

Code: Select all

#include "hbcompat.ch"
The above statement will introduce the following translate directives:

Code: Select all

   #xcommand TRY => BEGIN SEQUENCE WITH __BreakBlock()
   #xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->
   #xcommand FINALLY => ALWAYS
Keep it simple ;)

Re: TRY / CATCH / END

Posted: Sun Jun 11, 2023 10:08 am
by mol
How does ALWAYS work? I didn't know that statement

Re: TRY / CATCH / END

Posted: Mon Jun 12, 2023 4:49 pm
by AUGE_OHR
hi,

thx for all Answer