Topic
4 replies Latest Post - ‏2012-12-18T14:29:37Z by SystemAdmin
SystemAdmin
SystemAdmin
535 Posts
ACCEPTED ANSWER

Pinned topic Using Procedure Interfaces

‏2012-12-14T17:26:17Z |
Is there a way to use procedure interfaces (pi) without a prototype (pr) (prototypes are a real pain)? ...For instance using callb instead of callp, or callp without a prototype...?
Updated on 2012-12-18T14:29:37Z at 2012-12-18T14:29:37Z by SystemAdmin
  • barbara_morris
    barbara_morris
    372 Posts
    ACCEPTED ANSWER

    Re: Using Procedure Interfaces

    ‏2012-12-14T17:58:57Z  in response to SystemAdmin
    If the procedure is local (not exported), then in 7.1, you don't need to code a prototype.

    If the procedure is called from another RPG module, then in in 7.1, you do need to /copy the prototype into both the calling module and the module that defines the procedure.

    I wouldn't use CALLB. In the long run, it's much more of a pain to use CALLB than to code the prototype. For example, with CALLB you always need to code variables to pass as parameters, so you often need extra statements just to set up the parameter values.

    But the most important reason to take the trouble to use prototyped calls vs CALLB is that using prototyped calls can significantly reduce problems caused by mismatched parameters. Using prototypes isn't perfect - you still need to remember to recompile all the affected modules whenever you change the prototype, but it's easier to handle compile-time errors than to debug run-time errors. Especially the kind of run-time errors where the error shows up long after the problem occurred.
  • SystemAdmin
    SystemAdmin
    535 Posts
    ACCEPTED ANSWER

    Re: Using Procedure Interfaces

    ‏2012-12-14T19:03:45Z  in response to SystemAdmin
    Barbara,

    does the fact that I am using linear-main procs make any difference?
    • barbara_morris
      barbara_morris
      372 Posts
      ACCEPTED ANSWER

      Re: Using Procedure Interfaces

      ‏2012-12-14T22:15:22Z  in response to SystemAdmin
      I'm not sure I understand what you mean about linear-main procedures. Can you give more information about what problem you're having?

      But there's nothing different about a linear-main procedure that would cause it to need or not need a prototype to call it.

      Are you on 7.1 where prototypes are optional? If you are having to code a prototype for the linear main procedures because of needing to code the EXTPGM keyword, you can code the EXTPGM on the PI if there's no prototype.

      That would only be relevant if you are not calling your linear-main program from another RPG program. For example, you only call it from CL, or it is the CPP for a command.
  • SystemAdmin
    SystemAdmin
    535 Posts
    ACCEPTED ANSWER

    Re: Using Procedure Interfaces

    ‏2012-12-18T14:29:37Z  in response to SystemAdmin
    didn't think it would make a difference. Just thought I would ask. And yes, most of my procedures call other procedures...