View previous topic :: View next topic
|
Author |
Message |
Vineet
New User
Joined: 14 Sep 2005 Posts: 20
|
|
|
|
Hi All,
I have a small query. Lets say in a Cobol Pgm, in Working Storage Section I have Var. lets say:
01 VAR1 Pic x(3) value 'ABC' .
Now If I pass value of VAR1 to any called Pgm & in called Pgm value gets returned to VAR1 as 'XYZ', then during the execution of main Pgm.(After the Called Pgm), If I refer to Var1 what value will it be having 'ABC' or 'XYZ'. or does this mean that before the called Pgm. is encountered value of var1 going to be 'ABC' & after the called pgm. value going to be 'XYZ'.
Thanx |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Vineet,
Yeap u r right before the called Pgm encountered value of var1 going to be 'ABC' & after the called pgm. value going to be 'XYZ'. |
|
Back to top |
|
|
vin12pr Warnings : 1 New User
Joined: 14 Jun 2006 Posts: 56
|
|
|
|
Hi,
It depends on how you pass the variable to the called program:
1) If you pass the variable by "CALL BY REFERENCE" ,the modified value of the variable is expected to be visible in the main program.
2) If you pass the variable by "CALL BY VALUE" , the modified value of the variable will not be visible in the main program.
Correct me if am wrong...
Thanks ,
Vinay |
|
Back to top |
|
|
Vineet
New User
Joined: 14 Sep 2005 Posts: 20
|
|
|
|
Hi Ekta & Vinay thanx for the Help. I really Appreciate the effort you took to reply to my query. I have some more doubts.
1) Is it possible that while calling the called Pgm for the parameters we can have both "Call By Value" & "Call By Reference". For "Call By Value" does this means that we directly pass the value like:
Call "SubRout" using "ABC","XYZ"
And for "Call By Reference" does this mean that we pass value throug some Var. i.e. Call "SubRout" using Var1,Var2.
2) I red some where
if call by Reference: CALL PGM1 USING BY REFERENCE parm1
If Call by Value: CALL PGM1 USING BY VALUE parm1
If Call by Content: CALL PGM1 USING BY CONTENT parm1
what is meaning of "USING BY CONTENT"
Thanx |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Vineet,
First thing we dont code "Value" in Call statement of a Cobol program. I think above posts meant for Call by Content instead. And the changes in value of the variable should be as suugested by Vinay above.
Quote: |
1) Is it possible that while calling the called Pgm for the parameters we can have both "Call By Value" & "Call By Reference". |
Yes, you can have both Call by reference and Content in a single Call statement.
Quote: |
For "Call By Value" does this means that we directly pass the value like:
Call "SubRout" using "ABC","XYZ"
And for "Call By Reference" does this mean that we pass value throug some Var. i.e. Call "SubRout" using Var1,Var2. |
See here...
Quote: |
2) I red some where
if call by Reference: CALL PGM1 USING BY REFERENCE parm1
If Call by Value: CALL PGM1 USING BY VALUE parm1
If Call by Content: CALL PGM1 USING BY CONTENT parm1
what is meaning of "USING BY CONTENT" |
If you have gone thru above link... I dont think you are still looking for this answer... Are you? |
|
Back to top |
|
|
|