TRY / CATCH / END

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

TRY / CATCH / END

Post 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 ...
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: TRY / CATCH / END

Post by edk »

Maybe like that

Code: Select all

#xcommand TRY => BEGIN SEQUENCE WITH { |oErr| Break( oErr ) }
#xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: TRY / CATCH / END

Post 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 ;)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: TRY / CATCH / END

Post by mol »

How does ALWAYS work? I didn't know that statement
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TRY / CATCH / END

Post by AUGE_OHR »

hi,

thx for all Answer
have fun
Jimmy
Post Reply