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