[Info-vax] Returning data from Cobol AST routine.

Arne Vajhøj arne at vajhoej.dk
Tue Sep 21 09:00:51 EDT 2021


On 9/21/2021 3:15 AM, Jan-Erik Söderholm wrote:
> Den 2021-09-21 kl. 03:27, skrev Arne Vajhøj:
>> On 9/20/2021 6:55 PM, Jan-Erik Söderholm wrote:
>>> I have been looking at the Cobol AST example here:
>>> http://computer-programming-forum.com/48-cobol/b75d8c5fdd43048e.htm
>>>
>>> This does work fine as an example. But what are the options to get
>>> some data back to the main program (called "x" in the example)
>>> from the ast program (called "ast_routine" in the example)?
>>>
>>> I have tried different versions of global, external and so on, but
>>> no luck so far. How to get "x" and "ast_routine" to share some data?
>>> Anything similar to an COMMON area in Fortran?
>>>
>>> The idea is to have an AST routine that will read from a mailbox when
>>> something is written to it. My idea was that the read of the mailbox
>>> would be using an AST to avoid polling the mailbox.
>>>
>>> This is to have a command input to detached processes to get them to
>>> reload the config, repoen the log file, close and exit and so on.
>>>
>>> Are there more options if not everything is done in Cobol?
>>> We can easily add some C if that helps...
>>
>> external works for me.
>>
>> identification division.
>> program-id. x.
>> environment division.
>> data division.
>> working-storage section.
>> 01  magic-value         pic 9(10)  display external.
...
>> end program x.
>> identification division.
>> program-id. ast_routine.
>> environment division.
>> data division.
>> working-storage section.
>> 01  magic-value         pic s9(10)  display external.
...
>> end program ast_routine.
>>
>> $ cobol x
>> $ link x
>> $ run x
>> sleeping for 5 seconds
>> 000000012C
> 
> Ah, OK! that will be tested. Hm, is this limited to numeric variables?
> My test was using a x(3) variable...

Try it!

Per documentation then external just moves the variable to a PSECT
with the same name as the variable to tell the linker to overlay
them.

I would expect that to work with any data type.

> Hm, if this would had been a read-AST on a mailbos instead of a timer,
> maybe the ast_routine can just awake the main code and the mailbox
> been read in the main code. The ast_routine could set a variable that
> just signals the reason fo the wakeup.

I don't understand the problem.

If you want the main flow to wait until something is in the mailbox,
then why not do a blocking read?

Arne






More information about the Info-vax mailing list