× 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.



    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

TESTN is designed to validate a numeric field before using MOVE or a data structure to convert it to a number. TESTN considers many letters to be "valid numbers" because they'd fit in the negative sign zone of a zoned decimal field.


Trouble is -- you're not converting it to a zoned decimal field using MOVE. You're converting it to an INTEGER field using %INT()!!

Instead of using TESTN, use MONITOR. It's designed for exactly what you're trying to do:

     c                   monitor
     c                   eval      sctax# = %int(paytyp)
     c                   on-error
     c                   eval      msgdata = 'Invalid Transaction Type'
     c                   endmon

Some people will tell you to use %check(), but IMHO this is incorrect. For example, consider the string ' -1234'. This is a completely valid number for interpretation by %int() but it won't work if you validate it with %check('0123456789':myvar) because it contains both blanks and the negative sign. If you used %check('0123456790- ':myvar), then it would think that strings like '-------' or '- - - -' are valid numbers!

So, use MONITOR. If you expect a TON of errors, use %check() first to weed a lot of them out before using MONITOR, but still use MONITOR...

Good luck!




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.