[Info-vax] Returning data from Cobol AST routine.
Arne Vajhøj
arne at vajhoej.dk
Wed Sep 22 08:31:24 EDT 2021
On 9/22/2021 3:41 AM, Jan-Erik Söderholm wrote:
> Den 2021-09-22 kl. 03:37, skrev Arne Vajhøj:
>> On 9/21/2021 8:31 PM, Jan-Erik Söderholm wrote:
>>> 01 reqidt pic 9(9) comp.
>>> ...
>>> move 1234 to reqidt
>>> call "sys$setimr"
>>> using omitted
>>> by reference delta-time
>>> by value ast-proc-addr
>>> by reference reqidt <<==
>>> omitted
>>> giving return-value
>>> end-call
>>>
>>> Replaced "by value reqidt" with "by reference reqidt".
>>> That will pass the address (pointer) to reqidt.
>>> Silly not thinking about that...
>>>
>>> The AST routine just uses the paramater as-is as before
>>> an now prints "reqidt: 1234" as expected.
>>
>> I would probably have preferred to keep the formal
>> argument as by val and stuffed the address into an integer
>> and passed that. Slightly more complicated but I just
>> don't like faking the passing mechanism of a system
>> service.
>
> Not that much more complicated, one additional pointer definition:
>
> 01 reqidt_addr pointer value reference reqidt.
> 01 reqidt pic 9(9) comp.
> ...
> move 1234 to reqidt
>
> call "sys$setimr"
> using omitted
> by reference delta-time
> by value ast-proc-addr
> by value reqidt_addr
> omitted
> giving return-value
> end-call
>
> This also works. A matter of taste, I guess. :-)
Yes. They do the same thing.
It just bother me to see a by reference when the documentation
says by value even though there is a good reason.
Arne
More information about the Info-vax
mailing list