IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Pass By value and content


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mr.Niceguy

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Thu May 18, 2006 11:45 am
Reply with quote

Hi all,

Can anybody explain "pass by reference and content"?

Thanks alot
Back to top
View user's profile Send private message
shell100

New User


Joined: 14 Apr 2006
Posts: 25
Location: Banglore,India

PostPosted: Thu May 18, 2006 12:25 pm
Reply with quote

Hi,

In Pass by reference called program can modify the passed parameter & these changes will be reflected in calling program as well.

But in Pass by value , changes would not get reflect in calling program. Mainly used to pass read only parameter.
Back to top
View user's profile Send private message
ursprasanna
Warnings : 2

New User


Joined: 15 May 2006
Posts: 20
Location: chennai

PostPosted: Thu May 18, 2006 2:25 pm
Reply with quote

Hi,

Call by reference ---- here the address of the variable is passed from the called program to the calling program . to make it more clear ...if A, B , C are the values that are to be passed to the called program from the calling program . and consider that these variables are in the memory location 001A ,001B,001C respectively . in call by reference the the address are passed to the sub program . the sub -program also uses the same memory location on the main program . so the changes made in the sub program will be reflected in the main progarm .

call by content ---- here a copy of the data variables( A, B , C) is made and this is stored in a separte memory location and let this memeory location be ( 002A , 002B,002c) and the original memory location will be (001A,001B,001c) . Here ( call by content) the address of the copy of the variables willbe passes ie) ( 002A,002B,002C) .. so the values that are changed in the called program will not be reflected back in the main program.
Back to top
View user's profile Send private message
Mr.Niceguy

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Thu May 18, 2006 3:03 pm
Reply with quote

Hi,

Thanks Alot, Bust still need some more explanation for Call by content..

Just little bit confused.. can any body help me??

Bye
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Wed May 24, 2006 3:34 pm
Reply with quote

A simple way to understand this is,
Program A has a variable WS-MESSAGE-HEADER defined in its working storage. The memory address of this variable at run time is "001A".
Program A calls Program B
Program A wants to send some data to Program B to use. This is included in using clause of CALL statement
e.g.
Code:
CALL 'program_name'
                            USING
                            WS-MESSAGE-HEADER


Now, Program B has to refer the data passed in the variable WS-MESSAGE-HEADER.
There are two ways it can do it.
1) One way is to refer to memory address of that variable i.e. "001A" and pick up the content of the variable from there. In this case, if Program B makes any changes in the content, it will be at the same memory location. and so when Program B finishes after changing content of WS-MESSAGE-HEADER, those changes will be available to Program A. This is called, call by VALUE, which is default when not specified in CALL statement.

2) The other way is to avoid passing memory address of the working storage variable WS-MESSAGE-AREA. Instead, copy the content at memory address "001A" to a different memory address, say "00CA" and pass that memory address to Program B. This way, even if Program B changes the received data, when control goes back to Program A, the WS-MESSAGE-HEADER will contain the same data as it had before calling Program B.

sigh!!

This is what precisely was explained in ursprasanna's post. I have tried it in my way.

But more often than not you end up saying same things when answers are this simple.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Reformat and relocate content DFSORT/ICETOOL 4
No new posts Setting CA7 user variable from data s... CA Products 7
No new posts pass data as symbolic parameter from ... CLIST & REXX 2
Search our Forums:

Back to Top