CALL BY VALUE/CALL BY CONTENT



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

CALL BY VALUE/CALL BY CONTENT

Postby Falcon » Thu Mar 03, 2011 9:31 pm

Hi,
Could anyone explain the difference between CALL BY VALUE and CALL BY CONTENT phrases? Thanks in advance.
Regards,
Ian Padayachi
Falcon
 
Posts: 7
Joined: Fri Jul 09, 2010 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: CALL BY VALUE/CALL BY CONTENT

 

Re: CALL BY VALUE/CALL BY CONTENT

Postby Robert Sample » Thu Mar 03, 2011 11:20 pm

The manual states that BY CONTENT variables can be any level whereas BY VALUE must be elementary items only. There is a long list of restrictions on the BY VALUE variable in the Programming Guide manual, section 6.2.4.4.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: CALL BY VALUE/CALL BY CONTENT

Postby Zio69 » Fri Mar 04, 2011 3:53 pm

If you're familiar with Microsoft Basics (from QBASIC to VB.net), it's the same thing.
If you're not: BY REFERENCE, which is the way things have always been done on mainframes since S/360, will pass an address (a pointer) to the called program; that's the address of the variable you're passing to the called program; BY VALUE (or BY CONTENT) will copy the parameter to a temporary area and pass the address of the temporary area to the called program. Since the called program will receive a copy of your area, changes made by the called program won't have any effect on your original variable.
You can find some examples of this by looking at the compile listing of a program that went thru the CICS pre-compiler (at least from TS 1.x on): calls to CICS modules often mix BY REFERENCE / BY VALUE. Usually program areas are passed by reference while some literals are passed by value.
I.E.
*EXEC CICS ADDRESS CWA (ADDRESS OF CWA-AREA) END-EXEC.             
     Call 'DFHEI1' using by content x'0202800007020000000000000000
-    '0000000000000000f0f9f4f4f5404040' by reference ADDRESS OF   
     CWA-AREA end-call.                                           

*EXEC CICS SEND    MAP     ('XXXX')                           
*                  MAPSET  ('XXXX')                           
*                  CURSOR  (CURSORE)                             
*                  RESP    (WS-RESP) FRSET   END-EXEC.           
     Move 'XXXX' to dfhc0070                                   
     Move length of XXXXO to dfhb0020                         
     Move 'XXXX' to dfhc0071                                   
     Call 'DFHEI1' using by content x'1804f1002700c100001de0040000
-    '20f1f0f7f7f7404040' by reference dfhc0070 by reference     
     CROSAMCO by reference dfhb0020 by reference dfhc0071 by     
     content x'0000' by content x'0000' by content x'0000' by     
     reference CURSORE end-call                                   

IMHO: if you've got recurring strings to pass to called programs (dunno, like "YMD/DMY" or "OPEN"/"CLOSE" or whatever) you may want to try BY VALUE/BY CONTENT; otherwise I wouldn't bother. I guess IBM introduced them (together with RETURNING) for some POSIX/UNIX compliance or possibly for compatibility with C/C++. Possibly guys who know more will shed some light on this topic....
Zio69
 
Posts: 31
Joined: Wed Feb 16, 2011 7:08 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post