× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Ron,

<snip>
?* is the transaction type code numeric?
     c                   evalr     pay_type_test = paytyp  
     c                   testn                   pay_type_test          99
     c                   if        *in99
     c                   eval      sctax# = %int(paytyp)       
     c                   else
     c                   eval      msgdata = 'Invalid Transaction Type Code'
</snip>

I'd suggest using a MONITOR group:

1) In circumstances where errors are infrequent, it may run faster than
constantly checking, followed by conditional processing (if statements).
2) You are coding for success, but still trapping errors. This looks neater
(IMHO):

     c                   monitor
     c                   eval      sctax# = %int(paytyp)

     ?* If the transaction type code is not numeric, display error...
     c                   on-error
     c                   eval      msgdata = 'Invalid Transaction Type Code'
     c                   endmon

Here you've eliminated the need for pay_type_test and you allow the eval to
simply run. If there's an error it will be trapped and your message will be
displayed.

The great thing about using monitor groups is that you can "group"
statements, and monitor the lot. You can also have a hierarchy of on-error
blocks, starting with specific error types and getting more generic as you
go.

Very similar to using a java try-catch block, and definitely better than
littering your code with checks followed by if statements.

Cheers

Larry Ducie


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.