David J Murray Dev
~ Learn and Do - Excel and Share ~

Try and Catch: Part 2

Aug 16, 2007
You're Reading: Try and Catch: Part 2

A post in Free & Freebies & MVDBS & Techniques

Continuing from my first post on the wish for a Try and Catch control structure within the U2 products, I had decided to see if I could create one within SB+ using a new input screen which eventually automatically creates a SB+ Paragraph process.

The Try part of the structure will consist of a list of SB+ processes which will be executed top down until one returns an error code via RTN.FLAG. RTN.FLAG is a common variable which is used to pass back errors from all SB+ processes. If this flag is zero, then no errors has occurred. The possible values are documented within the SB+ manuals and in the online help. They can also be user created, but normally for error tracking, 0 is OK, 1 is an error.

So, to convert each process in the list to a SB+ Paragraph line would look like:

LOCAL CATCH.ERROR, CATCH.PROCESS
*
EXEC "processname"
*
IF @RTN.FLAG # 0 then
*
  CATCH.ERROR = @RTN.FLAG
  CATCH.PROCESS = processname
  GOTO 9999
END

The Catch part of the structure would consist of a CASE statement:

9999:
BEGIN CASE
CASE CATCH.ERROR = "1" AND CATCH.PROCESS = "processname"
*
  EXEC "processname"
CASE CATCH.ERROR = "1"
*
  EXEC "processname"
CASE CATCH.ERROR = "X"
*
  EXEC "processname"
CASE 1
*
EXEC "processname"
END CASE

So, if the following try and catch statement was:

TRY
*
  GET.USER.PARAMS
  GET.WEB.INFO
  PROCESS.TRANS
  CATCH "X" REVERSE.TRANS
*
END

then the resultant SB+ paragraph process would be:

EXEC "GET.USER.PARAMS"
IF @RTN.FLAG # 0 THEN
*
CATCH.ERROR = @RTN.FLAG
CATCH.PROCESS = "GET.USER.PARAMS"
GOTO 9999
END
*
EXEC "GET.WEB.INFO"
IF @RTN.FLAG # 0 THEN
*
  CATCH.ERROR = @RTN.FLAG
  CATCH.PROCESS = "GET.WEB.INFO"
  GOTO 9999
END
*
EXEC "PROCESS.TRANS"
IF @RTN.FLAG # 0 THEN
*
  CATCH.ERROR = @RTN.FLAG
  CATCH.PROCESS = "PROCESS.TRANS"
  GOTO 9999
END
*
GOTO 99991
*
9999:
BEGIN CASE
  CASE CATCH.ERROR = "X"
  CASE 1
  END CASE
99991:

Now it is just a matter of creating a SB+ paragraph within the xxPROCESS file and add all the SB+ internals…

About the Author

<a href="https://davidjmurray.dev/losucag/davidjmurray/" target="_self">djm</a>

djm

I have been in the computer/IT industry for over 35 years. After spending half a life-time in highly proprietary database environments, I have succumbed to the WordPress Eco-system and I'm well down the chasm. I am specializing in AWS hosting, Wordpress CMS, Elegant Themes, in particular Divi and Extra themes.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This