A Try/Catch construct is similar to the SQL TRANSACTION block - (BEGIN
TRANSACTION/END TRANSACTION) where if any statement within the block fails,
the sequence is stopped and action is taken. Within context to the SQL
TRANSACTION, a rollback is performed.

My thoughts come from the opening of multiple files at the start of a
routine. Each file is opened with either an OPEN statement, the SB+
SB.FILE.VAR.S routine, or similar and then a error check is performed. If an
error occurred, then there is no point in continuing with opening the other
files and some sort of error message and abort is performed.

This can get messy with a moderately large number of files to open and
really is just repeated grunt code. Using a Try/Catch construct around the
file open statements, if and when a open fails, the construct automatically
exits to an exception block and performs the error logging etc.

This is just a more elegant and tidier method than multiple OPEN ... ELSE
... END with common code or if using SB+ - CALL SB.FILE.VAR.S(); IF RTN.FLAG
NE 0 THEN ... END for each open.

A Try/Catch can also be used around other code sequences where a failure in
one statement should abort the total sequence; eg. socket handling.

A CASE construct is not the same as the Try/Catch - though internally, if
would involve a CASE for the detection and selection on the error code and
what action to perform on failure.



Ron Hutchings wrote:
> 
> 
> Since I was following this thread, I just could get it out of my head why
> the CASE syntax didn't do what you want.
> 
> The other thing that did occur to me, is it seems like your imposed
> restrictions would have applied to using the DEFFUN construct.  You could
> define several functions and use them at will throughout your code or wrap
> IF-THEN-ELSE logic around them as needed.
> 
> 
> 
> 


-----

Learn and Do
Excel and Share


http://mvdbs.com http://mvdbs.com 
-- 
View this message in context: 
http://old.nabble.com/Does-UV-have-a-%22BLOCK%22-command-tp30867376p30896461.html
Sent from the U2 - Users mailing list archive at Nabble.com.

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to