Admittedly I've never tried it, but I see no reason why one could not use ITER and LEAVESR op-codes in a cycle program. I.e., that the compiler would not issue a syntax error message.
I am guessing, though, that you mean using these op-codes in the context of processing the program's "primary" file, which would be true, at least as regards the ITER. But if you really want to get nasty, look up the FORCE op-code and try to imagine why you would ever need it. In over 35 years I've only seen it used once (RPG II), and my considered opinion was that it wasn't required then. But someone, somewhere must have needed it. And that points out another nice feature about the system: Backward compatibility; i.e., the FORCE op-code is still there (but, then, WSU ain't .-) ).
It should be noted that all structured op-codes are implemented (under the covers, that is) using branches/gotos/whatever.
Jerry C. Adams
IBM System i Programmer/Analyst
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of James Perkins
Sent: Thursday, January 08, 2009 2:15 PM
To: RPG programming on the IBM i / System i
Subject: Re: Good places to use "The Cycle" in today's RPG was->Re: FW: Niftiest thing(s) you have done in RPG ILE or /FREE
While I agree that GOTOs are not required in cycle programs, I have probably
only seen a handful of cycle programs that did not use them. There is
usually always some record you don't want.
Usually when I find cycle programs that do not have GOTOs, it's because they
are some kind of work file.
Personally I find the ITER or LEAVESR can always replace a GOTO, if and only
if it's not a cycle program ;-)
James R. Perkins
On Thu, Jan 8, 2009 at 11:50, Booth Martin <booth@xxxxxxxxxxxx> wrote:
GOTOs have nothing to with the cycle.
Also, GOTOs are pretty handy if there are no exsr, begsr, and endsr opcodes
As an Amazon Associate we earn from qualifying purchases.