View previous topic :: View next topic
|
Author |
Message |
kregen
New User
Joined: 16 Mar 2006 Posts: 21
|
|
|
|
hello all,
i need to know wich parameter is last given, when the subprogram is called.
Program a
call 'subpgm' using a, b, c
Program b
call 'subpgm' using a, b
Program c
call 'subpgm' using a
subpgm
linkage
01 a PIC x(10).
01 b PIC x(07).
01 c PIC x(05).
procedure division using a, b, c.
.
.
.
goback
how can i know how much paramters has the
mainprogram given to the subprogram?
regards
kai |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why do you want to know that?
The traditional way if there is a valid reason for a program to receive different numbers of parameters is to have something in the first item which indicates that. An IO-subroutine that knows from O(pen) and C(lose) that there is no record-area required, for instance. |
|
Back to top |
|
|
kregen
New User
Joined: 16 Mar 2006 Posts: 21
|
|
|
|
hi Bill,
i want to check that the mainprogram has given the parameters that the subprogramm needed.
example
function open no other parameter needed
function close no other parameter needed
function insert one other parateer is needed
function update two other parameter are needed
when the parameter wasn't give then the modul crash. i don't like it.
i want to give the result 'Parameter is Missing'.
In REXX have i no Problem to do this.
regards
Kai |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Are you saying that the sub-program actions the first parameter without first checking that any required subsequent parameter has been passed? If so, then do the proper thing and edit your parameters first BEFORE actioning. If necessary then have the calling program pass a parameter coiunt as the first parameter and move the other parameters down one (p1 becomes p2 etc). |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, COBOL isn't rexx.
It crashes or otherwise goes badly in testing. It gets fixed. Once it is fixed, there is nothing to worry about.
Once you are up-and-running, say that your subroutine is CALLed 100m times a day/week/month. You want to check each time that the correct number of parameters are used, even though it is only when there is a new use of the subroutine that could get the number of parameters wrong?
Whether you like it or not, matching the order and number of parameters on a CALL to the PROCEDURE DIVISION USING (or ENTRY USING) is down to the programmer. |
|
Back to top |
|
|
|