|
Would be nice if you could do something like IF numeric(string+'0') Indicators are so gauche. But I guess that is the point with subprocedures - just make your own function. However, as the one gent suggested, how would one handle a signed number? Let's say a string passed TESTN, and it was signed. Could you then move it into a numeric? Instead of being lazy, I decided to test it myself: D string S 5A D numeric S 5P 0 C eval string='0012G' C exsr test C eval string='00G12' C exsr test C eval *inlr=*on C* You know, I almost took the time to make this a subprocedure. C* In a production program I pretty much make all subroutines into C* subprocedures. C test begsr C TESTN string 80 C if *in80 C movel string numeric C else C eval numeric=*zeros C endif C numeric dsply C endsr DSPLY 127 DSPLY 0 Rob Berendt ================== Remember the Cole! D.BALE@handleman. com To: RPG400-L@midrange.com Sent by: cc: owner-rpg400-l@mi Subject: Re: TESTN drange.com 10/31/00 04:03 PM Please respond to RPG400-L Scott, I love that idea! Simple and elegant. I can't tell you the number of times I've cursed TESTN for this problem. Heck, you could make it a lot more universal and define WORK as a 31-byte alpha, instead of 4. Another tip for my toolbox! Dan Bale IT - AS/400 Handleman Company 248-362-4400 Ext. 4952 -------------------------- Original Message -------------------------- '12G' is a character representation of the number -127. When you MOVE a negative number to a character field, it changes the value of the "zone" portion of rightmost byte to reflect that its a negative number. (The change will usually result in a letter from A-R or the "{" character.) Therefore "12G" is a valid number. If you only want to test for valid positive numbers, do something like this: C MOVEL '12G' SIN 3 C MOVE *zeros WORK 4 C MOVEL SIN WORK C TESTN WORK 81 c eval *inlr = *on By putting that extra zero at the end, the "G" ends up in the middle of the number, and will signal an error. On Tue, 31 Oct 2000, Lurton Keel wrote: > Here is a program. > C MOVEL '12G' SIN 3 > C TESTN SIN 81 > c eval *inlr = *on > indicator 81 is in pos 71-72. > My problem is that in the above example, indicator 81 is on even though > there is a "G" in the field. > The RPG reference says. > "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." > What's up > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
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.