|
Also to clarify, the 'Other' opcode is similarly available in the If/ElseIf To take Michael's example and modify it: Exfmt Screen If KeyPressed = Enter do something ElseIf KeyPressed = F3 exit from program Else Backup EndIf -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Michael Jacobsen Sent: Thursday, December 30, 2004 7:41 AM To: RPG programming on the AS400 / iSeries Subject: Re: Select/When vs. If/ElseIf > Here is an example of when I would use select over an If/Else With the > Select you don't have all the endif's & I think it is easier to > understand. I just wanted to clarify that with If/ElseIf you don't need "all the endif's". When the opcode ELSEIF was added in V5R1 I believe, it eliminated the need to code multiple EndIf's. Ex: Exfmt Screen If KeyPressed = Enter do something ElseIf KeyPressed = F3 exit from program ElseIf Keypressed = F12 Backup EndIf The above does the same as a select/when only is 1 line shorter because there is no Select statement at the beginning. And adding a ELSE at the end would work the same as OTHER. But I agree with Jon Paris on when to use what. For the above example, I would probably use a Select instead since the same field is being tested for different values. Mike Mike -- This is the RPG programming on the AS400 / iSeries (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-2025 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.