|
Using the example: For X = A by B to C A and B can be any positive or negative number C must be any number greater than A Which presents a problem with counting backwards. You can try various values with the code below. There's a hard-coded internal limit of 25 in the source. Also note that everyone's favorite OpCode in a loop works too and one last note, it doesn't prompt correctly. Free-form works and you can obviously split the line but it won't prompt correctly, in fact, if you prompt the second line SEU gets a little confused but you can beat it into submission with a F13 syntax check. ========================================================== CMD PROMPT('JUNK') PARM KWD(A) TYPE(*DEC) LEN(3 0) + PROMPT('initial value') PARM KWD(B) TYPE(*DEC) LEN(3 0) PROMPT('for + by value') PARM KWD(C) TYPE(*DEC) LEN(3 0) PROMPT('for + to value') d forVar s 3p 0 counting variable d A s 3p 0 initialize counter d B s 3p 0 increment d C s 3p 0 limit d safeTValve s 3p 0 inz(0) endless loop stopper c *entry plist c parm A c parm B c parm C C for forVar = A by B test this C to C c eval safeTValve=safeTValve+1 loop stopper++ c if safeTValve>25 check stopper c leave our favorite opcode c endif c forVar dsply whatever c endfor test this end c eval *inlr=*on clean mem C return bail out ----- Original Message ----- From: Chris Bipes <chris.bipes@cross-check.com> To: <MIDRANGE-L@midrange.com> Sent: Monday, November 06, 2000 10:58 AM Subject: RE: FOR loop available in RPG IV For X = 1 by 3 to 100 "the real work" .... EndFor From the Book: +-------------------------------------------------------------------------- ¦ Code ¦ Factor 1 ¦ Extended Factor 2 +-------------------------------------------------------------------------- ¦ FOR ¦ ¦ Index-name = start-value BY increment TO/ ¦ ¦ ¦ DOWNTO limit +-------------------------------------------------------------------------- Christopher K. Bipes mailto:ChrisB@Cross-Check.com Sr. Programmer/Analyst mailto:Chris_Bipes@Yahoo.com CrossCheck, Inc. http://www.cross-check.com 6119 State Farm Drive Phone: 707 586-0551 x 1102 Rohnert Park CA 94928 Fax: 707 586-1884 If consistency is the hobgoblin of little minds, only geniuses work here. Karen Herbelin - Readers Digest 3/2000 -----Original Message----- From: Erick Garske [mailto:erick@formationmg.com] Sent: Monday, November 06, 2000 7:27 AM To: midrange-l@midrange.com Subject: FOR loop available in RPG IV I heard recently that there is a FOR loop available in RPG IV (no pun intended). The SEU editor will accept it and it looks like there is an ENDFOR statement as well. Has anyone here used the FOR loop syntax? Is it exactly like the do syntax? Erick Garske, Software Engineer FORMation mg http://www.formatinomg.com <http://www.formatinomg.com/> mailto:erick@formationmg.com Voice: (949) 598-8890 x 108 Fax: (949) 598-8899 Eliminate the cost of preprinted forms forever +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.