Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Pass By value and content

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Pass By value and content
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    Post subject:
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    Post subject:
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    Post subject: Re: Pass By value and content
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get and display content of an address... lind sh CICS 1 Mon Aug 08, 2016 9:18 am
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm
No new posts how to pass data from a rexx program ... Akshay Yadav TSO/ISPF 8 Mon Feb 15, 2016 12:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us