How about using regex? The regular expression = '^[0-9' + '+-]' or any
other characters you will be looking for.
If (regexec( compiledRegularExpression : %char(chk1) : 0 : match : 0 )
= 0);
// Success! You have a number you are looking for
endif;
More than is needed?
Gary
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, November 02, 2011 1:46 PM
To: RPG programming on the IBM i / System i
Subject: Re: Nested IF, OR and AND in /free
Hello,
Hmm, one of the first problems that comes to mind with the %char bif
is zero. What if you wanted to test for 0 in your list? I think
%char(0) returns a zero length string...
Huh? Why would %CHAR(0) return a zero length string? It'd return a
string one character long containing '0'.
Do you need to accommodate negative values? If so, I'd suggest
%editc(chk1 : 'J') and test for values padded with space (positive) or
a "-".
%EDITC doesn't trim blanks, so you'd have to add an additional %TRIM()
to your statement. Yuck. Again, what's wrong with %char() here?
if %scan(%char(chk1): '-1|-7|-8|-9') > 0;
I don't see why that wouldn't work?
For the record: I don't like any of these %SCAN kludges. I'd much
rather see the normal if/or/and syntax that already exists in RPG. That
will perform better _and_ it's easier to read/maintain. But, if you
must use an ugly kludge, I'd rather see %CHAR() than %TRIM(%EDITC())
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.