Even they are redundancy I use SELECT and IF/ELSEUF them "differently".

If I check different entries within the same variable(s), I use SELECT. For

When FLDA = 'A';
When FLDB = 'B;


When FldX = 'A' and FldY = 'B';
When FldX = 'X' and FldY <> 'B'
When FldX <> 'A' and FldX <> 'X' and FldY = 'C'

If I have to check different conditions I use IF / ELSEIF. For examples:
If FLDA = 'X' and FLDB = 'Y';
ElseIF FLDC = 1;

(Param3 and Param2 are different fields)
If %Parms >= %ParmNum(Param3) and Param3 > '';
ElseIf %Parms >= %ParmNum(Param2) and Param2 > *Zeros;

... but these are only my private rules

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Mark
Sent: Freitag, 25. Januar 2019 22:02
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: select vs. if-elseif

Does anyone else find the redundancy between the select block and the
if-elseif-else block a little disconcerting? Seems to me that there should
be a clear distinction between the two. There never can be at this point, so
I tend to use a relatively inconsistent mix of the two in my code based on
what mood I am in. But the select syntax has a potentially game changing

select <variable>;
when <value>;
when <value>;
when <value>;

This syntax reduces redundancy in a significant amount of code, by reducing
the need to retype code variable names over and over again.
Wouldn't it be nice?
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 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].