× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Joe,

> I'm having a bear of a time with this today.  I set up a prototype and
> an interface to my program, and when I call it, it immediately goes into
> a hard loop.  I can't breakpoint it or anything.
>
> I tried exporting the procedure interface, but it won't allow that.
> What am I doing wrong?

[SNIP]
> D MainMenu        pr
> P MainMenu        b
> D                 pi
> P                 e

What you've done is created a prototype and procedure interface for a
SUBprocedure, rather than the main procedure.   The P-spec is not used for
main procedures.

Remove the P-specs, and add an EXTPGM to the prototype.  The result should
be something like this:

  D MainMenu        PR                  ExtPgm('MAINMENU')
  D MainMenu        PI

>
> That's it!  And it loops forever.
>

It loops forever because you've got an empty main procedure. The RPG cycle
will cause your program to loop until you set on the LR indicator, or
until you execute a RETURN statement.   (You must be setting on *INLR in
your MainMenu() subprocedure, otherwise the compiler would stop with
"Can't determine how program can end" error.)

You can accomplish the same thing in any version of RPG IV by writing a
program like the following (this is the entire program)

c     MySubroutine  begsr
c                   eval      *inlr = *on
c                   endsr

Like yours, this one will loop forever.  The only difference is that I
used a subroutine instead of a subprocedure.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.