Page 1 of 1

Call by value

PostPosted: Sun Oct 06, 2013 1:41 pm
by Deepak kumar25
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

Re: Call by value

PostPosted: Sun Oct 06, 2013 7:35 pm
by Robert Sample
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.

Re: Call by value

PostPosted: Mon Oct 07, 2013 10:35 am
by Deepak kumar25
@ 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

Re: Call by value

PostPosted: Mon Oct 07, 2013 2:49 pm
by Robert Sample
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.

Re: Call by value

PostPosted: Mon Oct 07, 2013 7:03 pm
by Deepak kumar25
thanks robert for your help...