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



Title: RE: Numeric from Alpha
Ever since I had to fix a program at 2AM that failed as a result of a false positive from TESTN, I've been leery of it.  Here's an extract from TFM:

"The TESTN operation tests a character result field for the presence of zoned decimal digits and blanks. The result field must be a character field.  To be considered
numeric, each character in the field, except the low-order character, must contain a hexadecimal F zone and a digit (0 through 9). The low-order character is
numeric if it contains a hexadecimal C, hexadecimal D, or hexadecimal F zone, and a digit (0 through 9). Note that the alphabetic characters J through R, should they
appear in the low-order position of a field, are treated as negative numbers by TESTN. As a result of the test, resulting indicators are set on as follows:
 
   Positions 71 and 72: Either the result field contains numeric characters, or it contains a 1-character field that consists of a letter from A to R.
 
   Positions 73 and 74: The result field contains both numeric characters and at least one leading blank. For example, the values 123 or 123 set this indicator on. " 
   
Try running the following in debug:
 
 Dsuspect          s              5    inz('1234N')                    
 C                   testn                   suspect              99   
 C                   eval      *inlr = *on                             
 
 
I usually use the CHECK opcode for situations where I know there won't be signs or separators.  Array lookup is probably about as efficient.
 
 
-----Original Message-----
From: Leisk, Andrew [mailto:aleisk@frpaper.com]
Sent: Tuesday, June 13, 2000 11:59 AM
To: 'MIDRANGE-L@midrange.com'
Subject: RE: Numeric from Alpha

While you still have to do a bit of work the TESTN opcode in RPG does a pretty simple and straight forward test to see if an alpha field can be directly converted into a numeric field using a MOVE opcode

Im sure there are more complex ways of doing this and testing for decimals points and negative signs and the like, but for a 'quick' check TESTN may be old fashioned but works just fine.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.