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



For those of you who "C", it kind of jumps out as 1 OR 7 OR 8......


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of John Yeung
Sent: Wednesday, November 02, 2011 11:05 AM
To: RPG programming on the IBM i / System i
Subject: Re: Nested IF, OR and AND in /free

On Wed, Nov 2, 2011 at 11:53 AM, DeLong, Eric <EDeLong@xxxxxxxxxxxxxxx> wrote:
While not EXACTLY an "in list" function, for the example below, there is a hack...

If ( %scan(chk1 : '1|7|8|9') > 0 ) and chk6 <> '  '

Nice! The pipes serve both to make it clearer *and* to make it more
flexible (compared to solutions based on %check, for example). In
this form, it even *looks* a bit like "if myvar in (val1, val2,
val3)".

I appreciate the concerns some may have that this is on the "clever"
side, but I think it's just part of learning a language more fully.
Once learned, a neat and compact idiom like this can be faster to read
than a more verbose and cluttered one. (Though nicer still would be
for IBM to add direct support for an in-values construct. Even if you
like this %scan trick, it doesn't work for numeric values.)

John

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.