View previous topic :: View next topic
|
Author |
Message |
lucky.rohith Currently Banned New User
Joined: 06 Aug 2006 Posts: 10
|
|
|
|
Hi,
In C-language ter is a possibility of passing an array to the called program.
But is ther any possibility of passing arrays to called programs in COBOL.
If its is possible then were v hav to read the array either in the called or calling program. |
|
Back to top |
|
|
kondakonda
New User
Joined: 20 Mar 2006 Posts: 34
|
|
|
|
in COBOL an array element can only be passed to the subprogram not an array itself. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Yes you can pass an array to a called program.
Code: |
01 YOUR-ARRAY.
02 ARRAY OCCURS 500 TIMES.
05
05
:
CALL ?YOURSUB? USING YOUR-ARRAY.
|
In the called (subroutine) define the array in the LINKAGE SECTION the same as in the main program.
Dave |
|
Back to top |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
Hi
Please see below how an array is passed to a called program(passtab) and return some value to the calling program.
Regards
Aji Cherian
**********************************
01 a.
02 b occurs 2 times.
03 c pic 99.
01 i pic 9 value 0.
01 so pic 99 value 0.
procedure division.
p1.
perform p2 varying i from 1 by 1 until i > 2.
call "passtab" using a so.
cancel "passtab".
display so.
stop run.
p2.
accept c(i).
********see passtab program below
01 i pic 9 value 0.
linkage section.
01 a.
02 b occurs 2 times.
03 c pic 99.
01 tot pic 99 value 0.
procedure division using a tot.
p1.
perform p2 varying i from 1 by 1 until i > 2.
exit program.
p2.
display c(i).
add c(i) to tot. |
|
Back to top |
|
|
kondakonda
New User
Joined: 20 Mar 2006 Posts: 34
|
|
|
|
Yes, we can pass the array. David is right. |
|
Back to top |
|
|
|