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



You could easily write separate IN procedures for character strings or
numeric values (although they obviously couldn't both be called 'IN'). Or,
with some 'trickery', write a single procedure that can cope with both (as
well as dates, times, timestamps etc.)...

On Wed, Nov 2, 2011 at 11:04 AM, John Yeung <gallium.arsenide@xxxxxxxxx>wrote:

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

Follow-Ups:
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.