× 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, Garry:

IMHO, using regex for this is like backing up a whole dumptruck to move a shovel-full of dirt. *:-o*

Mark S. Waterbury

> On 11/2/2011 5:34 PM, Monnier, Gary wrote:
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.

This thread ...

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.