|
I use a similar method.... FDISFILE CF E WORKSTN INDDS(Indicators) F INFDS(Information) D Information DS D KeyPressed 369 369 D ExitKey C x'33' D PromptKey C x'34' D EnterKey C x'F1' D ErrorsExist PR N D Prompt PR DoW KeyPressed <> ExitKey; EXFMT FORMAT; IF KeyPressed = PromptKey; Prompt(); ElseIF KeyPressed = EnterKey; If not ErrorsExist(); Leave; EndIf; ENDIF; ENDDO; Michael Schutte Admin Professional Bob Evans Farms, Inc. For hotcake tips, interviews with our chefs and more, check out the Stacked and Stuffed blog at http://imstuffed.blogspot.com Jerry Adams <jerry@bwwholesal e.com> To Sent by: RPG programming on the AS400 / rpg400-l-bounces@ iSeries <rpg400-l@xxxxxxxxxxxx> midrange.com cc Subject 03/01/2007 09:35 Re: CHAIN Versus SETLL and READ AM When Data Needed Please respond to RPG programming on the AS400 / iSeries <rpg400-l@midrang e.com> While I've seen those kinds of constructs used, I personally don't like them because they usually don't tell me anything. I do use LEAVE, though, in subroutines that read a display file format over and over, such as: DOW F3 <> *On; EXFMT FORMAT; IF F3 = *On; LEAVE; ENDIF; [stuff] ENDDO; Others probably have a cleaner way of doing this. As for the ITER, I try to avoid it, but don't always. I may be in a DOx loop that has general test criteria, such as account_number = something. But within that construct, I may want to test further for other conditions (such as Booth's red-haired girls). This can be handled with IF, of course. But ITER can work, too, to avoid deep nesting. I once had to maintain a program (not here) where I identified 53 (count 'em!) nests before I quit counting. The chief programmer (a CDP) considered this a structured program. * Jerry C. Adams *IBM System i5/iSeries Programmer/Analyst B&W Wholesale Distributors, Inc.* * voice 615.995.7024 fax 615.995.1201 email jerry@xxxxxxxxxxxxxxx <mailto:jerry@xxxxxxxxxxxxxxx> Wes Reinhold wrote:
There was a lot of 'bad mouthing' of iter, leave, etc. yesterday. How would you get out of a DOW 0=0 without using them? -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx Sent: Thursday, March 01, 2007 8:44 AM To: RPG programming on the AS400 / iSeries Subject: Re: CHAIN Versus SETLL and READ When Data Needed Interesting. Haven't used procedure pointers. So, do you think your coworkers would find the use of procedure pointers clearer than the use of ITER or LEAVE? Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com "Chris Pando" <chris@xxxxxxxxx> Sent by: rpg400-l-bounces@xxxxxxxxxxxx 02/28/2007 05:04 PM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> cc Fax to Subject Re: CHAIN Versus SETLL and READ When Data Needed On 2/28/07, rob@xxxxxxxxx <rob@xxxxxxxxx> wrote:Yes, actually, it is too much to expect. I tried to follow that rulebutit got too ugly with nested if's and stuff to put logic around eachpartto see if it's time to exit Dou KissOff; if this; // else; // EndIf; If not KissOff; if ...; // EndIf; EndIf; If not KissOff; If ...; // EndIf; EndIf; If not KissOff; If ...; // EndIf; EndIf; EndDo;I have to deal with similar circustances all the time - as an example, I have a program with ten (10) consecutive procedures to execute. If any of them fail, I want to stop processing. I create an array (@procProxy@) containing pointers to the procedures, each of which returns KissOff. I then create a proxy procedure (procProxy) based upon the procedure pointer procProxy@. Then my code looks like this: $I = 0; DoU ( KissOff Or $I = %Elem(@procProxy@) ); $I = $I + 1; procProxy@ = @procProxy@($I)); KissOff = procProxy(); EndDo; The Do loop has a true invariant, and GOTOs aren't necessary. Chris "IMHFO" Pando -- chris@xxxxxxxxx | Every normal man must be tempted at www.pando.org | imes to spit on his hands, hoist | the black flag, and begin slitting | throats. H. L. Mencken
-- 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-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.