Call by value



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Call by value

Postby Deepak kumar25 » Sun Oct 06, 2013 1:41 pm

Dear experts,

I have a confusion in call by reference, call by content and call by value.
I know call by reference use to share same memory area in both calling and called program. and call by content used seprate local copy of arguments passed by calling program. and change in called program does not reflect back in calling program as their called program use a local copy of data.
But my question is that in what situations we use call by reference, call by content and call by value.
Means, i have two programs.
Program A
program B.
How do i know i should use call by reference or call by content.....
Please give me answer, thanks in advance.



Thanks
With Regards.
Deepak kumar
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time

Re: Call by value

 

Re: Call by value

Postby Robert Sample » Sun Oct 06, 2013 7:35 pm

Have you read the section of the Enterrpise COBOL Programming Guide manual that gives, with examples, the differences between the three CALL types? If not, you need to start by reading that materieal. The chapter is titled Sharing Data and is chapter 25 in the version 5.1 manual and 4.2 in the previous versions. If you have questions after reviewing this material, please post again.
Robert Sample
Global moderator
 
Posts: 3378
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 225 times

Re: Call by value

Postby Deepak kumar25 » Mon Oct 07, 2013 10:35 am

@ Robert sample.....thanks of reply

I have already read. but my question is that in which scenerio we use call by reference and call by content.
Means if want to call a program then how do i know that i should use call by reference and call by content.

I know call by reference share same memory area of calling and called program, and any change in called program will reflect in calling program. And in content memory area is different any change in called program would not reflect in calling area.

But what is the criteria of using both call.


I am confused.........help me
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time

Re: Call by value

Postby Robert Sample » Mon Oct 07, 2013 2:49 pm

The answer depends upon what you are trying to do in the subprogram. If you want to guarantee that the subprogram is not changing the calling program values, use CALL BY CONTENT or CALL BY VALUE. If you don't care if the subprogram changes the calling program values, use CALL BY REFERENCE. As stated in the material I cited, if you are calling a C or C++ program then you need to use CALL BY VALUE. You may need the RETURNING phrase, depending again upon what you are attempting to do. There are some differences between CALL BY CONTENT and CALL BY VALUE, but since this is a beginner's forum those differences do not need to be discussed.
Robert Sample
Global moderator
 
Posts: 3378
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 225 times

Re: Call by value

Postby Deepak kumar25 » Mon Oct 07, 2013 7:03 pm

thanks robert for your help...
Deepak kumar25
 
Posts: 34
Joined: Mon Jan 10, 2011 10:51 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post