HP3000-L Archives

October 1997, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Stigers, Greg ~ AND" <[log in to unmask]>
Reply To:
Stigers, Greg ~ AND
Date:
Thu, 30 Oct 1997 15:35:33 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (63 lines)
This is kind of what I meant about we COBOL programmers... I mean no
offense, and I don't know if John is a primarily a COBOL or C
programmer, or both, but COBOL * does * allow you to pass the address
instead of the reference. How well this is implemented in HP COBOL, I am
less sure of, primarily because I have yet to have to use these, which
is in itself unfortunate. For instance, this would not be a bad way to
call a validation subprogram.

Quoting from Donald Nelson's must-have book, COBOL 85 for Programmers
(not to be confused with Jim Ingris's book of the same title), p 116 in
the section on the CALL statement:

<<The terms BY REFERENCE and BY CONTENT are new in COBOL 85. BY
REFERENCE means that the address of the parameter is passed to the
called program, and that program acts on the data in the calling
program. Any change made in the called program changes the data in the
calling program. That is the default, and it is the way parameter
passing has worked in COBOL until COBOL 85. Now, you can specify BY
CONTENT. If you do, the calling program reserves space for the
parameter, the parameter data is move to the space and the address of
the space is passed to the called program. Any change the called program
makes to the data does not change the parameter data in the calling
program. >>

Now, HP COBOL * seems * to be doing this differently, as the HP COBOL
II/XL Reference Manual has:
<<The  BY CONTENT phrase is a feature of the 1985 ANSI COBOL standard.

If the BY CONTENT phrase is specified or implied for a parameter, the
called program cannot change the value of this parameter as referenced
in the CALL statement's USING phrase.  However, the called program may
change the value of the data item referenced by the corresponding data
name in the called program's division header.  That is, if the called
program changes the value, the calling program never sees the change.
 <snip>
NOTE  Do not use the BY CONTENT phrase when calling non-COBOL
subprograms that contain value parameters. BY CONTENT is not the same as
BY VALUE.>>

>----------
>From:  John D. Alleyn-Day[SMTP:[log in to unmask]]
>Sent:  Thursday, October 30, 1997 1:35 AM
>To:    [log in to unmask]
>Subject:       Re: [HP3000-L] Using Intrinsics with C
>
>"Anderson, Michael" <[log in to unmask]> wrote:
>
>The ampersand tells C that you want the address of the variable.  In COBOL
>all the variables are passed by reference anyway, so no ampersand is
>needed.  HP has a special format using "\"s to indicate that you are
>passing a variable by value (only used, of course, when calling a system
>intrinsic or non-COBOL program).  The compiler knows whether a variable has
>to be passed by value or by reference if you use "CALL INTRINSIC", so you
>can usually just miss out the "\"s.  C is much less forgiving, but allows
>you to do things that would be very difficult to do in COBOL.  Yer pays yer
>money and yer takes yer choice.
>
>John D. Alleyn-Day
>Alleyn-Day International
>408-286-6421   408-286-6474 (Fax)
>[log in to unmask]       http://www.Alleyn-Day.com
>

ATOM RSS1 RSS2