View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi
I have some subroutines declared in my PL/1 program as below.
DCL RPFREAD ENTRY(*,*);
DCL RPFOPEN ENTRY(*);
DCL SGMGS EXTERNAL ENTRY(*,*);
Can any one explain the difference between Entry and External Entry statements in PL/1? |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
An external procedure is one whose text is not contained in any other block. The source text of an external procedure can be compiled separately from that of a calling procedure. The differences between internal and external procedures are as follows:
Before an external procedure can be invoked (except through an entry variable), its name must be declared within the procedure that invokes it. The DECLARE statement for the external entry name must also provide a list of parameter descriptors that give the data types of the parameters that the procedure requires, if any, as well as a RETURNS attribute for a function procedure.
You cannot explicitly declare internal procedures. The procedure name is implicitly declared by its occurrence in the PROCEDURE or ENTRY statement.
External procedures can reference the same variable only if it is declared (implicitly or explicitly) with the EXTERNAL attribute in all of them.
An internal procedure, on the other hand, can reference internal variables declared in any procedure in which it is contained.
Any procedure can call an external procedure.
An internal procedure can be called only by the procedure that contains it or by other procedures at the same level of nesting within the containing procedure. The only exception is invocation through an entry variable. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Srihari Gonugunta wrote: |
Before an external procedure can be invoked (except through an entry variable), its name must be declared within the procedure that invokes it. The DECLARE statement for the external entry name must also provide a list of parameter descriptors that give the data types of the parameters that the procedure requires, if any, as well as a RETURNS attribute for a function procedure. |
- it does not have to be declared, the compiler is in many instances smart enough to assume that it is dealing with external entries
- a list of parameters is never compulsory
- if no returns attribute is given, normal PL/I rules for identifier names are followed
|
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Thanks Prins,
Still I am not clear with the ENTRY and EXTERNAL ENTRY keywords.
Can you please clarify the difference between ENTRY and EXTERNAL ENTRY with an example?
Thanks in advance. |
|
Back to top |
|
|
sai.dara
New User
Joined: 24 Aug 2007 Posts: 12 Location: Hyderabad
|
|
|
|
are you familiar with JCLs
External Entry is similar to Cataloged Procs and Entry is similar to Instream procs.
External Entry statement says that there is a submodule which will be used in this module. This external module is already coded, compiled and tested. Its definition is not coded in the current module. This helps in modularising your code, re usability of your code and thus easily maintained.
in your example it is DCL SGMGS EXTERNAL ENTRY(*,*);
Where as in
DCL RPFREAD ENTRY(*,*);
DCL RPFOPEN ENTRY(*);
these two submodules are defined/coded in the current module.
They are not visible outside this module.
is this clear ?
Thanks,
Sai |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Sai,
But all the three modules which I mentioned are coded outside of the current/main module.
Main module is just calling all the three submodules with CALL statement. It seems your answer need to correct.
Can anyone explain please? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Sai's answer is utter billshut and he obviously didn't even try to compile something like:
Code: |
PRINO: PROC OPTIONS(MAIN) REORDER;
DCL IN ENTRY();
IN: PROC;
END IN;
END PRINO; |
because it results in a
Code: |
IBM1306I E 2 Repeated declaration of IN is invalid and will be
ignored. |
error message.
The simple answer is that ENTRY declares are IMPLICITELY external, so there isn't one feck difference between
and
Code: |
dcl entry entry ext; |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
why do You post the same question in multiple forums ?
choose one and stick to it |
|
Back to top |
|
|
|