|
Scott Klement's code (below) is provides an elegant solution to the "no-goto-in-FreeForm-RPG" problem; it is miles ahead of the DOU *IN03 espoused by some RPG purists. (deep breath) What bothers me about this kind of solution is that additional logic is being introduced to control program flow. Yes, CABxx and CASxx meld logic and branching, but I'd consider their (let's include ITER, LEAVE, and LEAVESR in the grouping) use to be in the second order of complexity while a simple GOTO is the first order of complexity. Understanding how a SELECT group works is not intuitive. Scott's solution is an excellent template. However, logic is not required to figure out what GOTO means, and in the interest of discussing the presenting problem in isolation, I'm assuming a given program's coding technique did not include a side order of marinara. Alteration of program flow is a fact of life. You can let the RPG cycle do it for you (if you don't mind the purists' snickering behind your back), or you can do it yourself, in a style suitable for the task and for the eventual maintenance activity, or (in the case of interactive programs) you can train the users to do it right the first time. I remain bewildered why the GOTO/TAG construct was dropped from the freeform specification; it's just another one of life's mysteries. My application package, currently running 900,000 lines of RPG in 1,500 application programs (there's a lot of reusable code), features a large number of application panels individually supported by a unique help panel and a combination of standard and panel-specific command keys. I've done a fair amount of white-board and back-of-the-envelope scribbling to figure out a "better" way that works for the application and for what my customers expect; so far, my standard template with "just enough" GOTO's (exclusively for display file management) holds up well. Program flow is a key part of any business application, and I'd suggest it's just as important as the user interface design and the editing/processing functions. There are other considerations: my customers' technical staffs have varying levels of skill, and Scott's design is better suited for new development than for retrofitting. I'm remaining agnostic on FreeForm RPG; "NOTO" is one of the big reasons... -reeve ---------------------------------------------------------------------------- ----------------------- > D GetItemNumber PR 1N > D ItemNo 5P 0 > > D LoadInventory PR 1N > D ItemNo 5P 0 value > > D ShowInventory PR 1N > D ItemNo 5P 0 value > > D LoadOrders PR 1N > D ItemNo 5P 0 value > > D ShowOrders PR 1N > D ItemNo 5P 0 value > > D MyItem s 5P 0 > D Step s 10I 0 > > D SUCCESS C const('1') > D FAIL C const('0') > > D STEP_GETITEM C const(0) > D STEP_LOADINV C const(1) > D STEP_SHOWINV C const(2) > D STEP_LOADORDS C const(3) > D STEP_SHOWORDS C const(4) > D STEP_EXIT C const(5) > > /free > > dow Step <> STEP_EXIT; > > select; > when Step = STEP_GETITEM; > if (GetItemNumber(MyItem) = FAIL); > Step = STEP_EXIT; > else; > Step = Step + 1; > endif; > > when Step = STEP_LOADINV; > if (LoadInventory(MyItem) = FAIL); > Step = STEP_GETITEM; > else; > Step = Step + 1; > endif; > > when Step = STEP_SHOWINV; > if (ShowInventory(MyItem) = FAIL); > Step = STEP_GETITEM; > else; > Step = Step + 1; > endif; > > when Step = STEP_LOADORDS; > if (LoadOrders(MyItem) = FAIL); > Step = STEP_SHOWINV; > else; > Step = Step + 1; > endif; > > when Step = STEP_SHOWORDS; > if (ShowOrders(MyItem) = FAIL); > Step = STEP_SHOWINV; > else; > Step = Step + 1; > endif; > > endsl; > > enddo; > > *inlr = *on; > return; > > /end-free > > > *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > * GetItemNumber(): Ask the user for an item number > * > * ItemNo = (output) Item number retrieved from user > * > * Returns SUCCESS if item was entered, or FAIL if F3 pressed. > *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > P GetItemNumber B > D GetItemNumber PI 1N > D ItemNo 5P 0 > /free > > dou scMsg = *blanks; > > exfmt WIEITMS1; > scMsg = *blanks; > > if (key_F3); > return FAIL; > endif; > > if (scItem = 0); > scMsg = 'You must enter an item number!'; > endif; > > enddo; > > ItemNo = scItem; > return SUCCESS; > > /end-free > P E
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.