> In message <87372ECCA42DD3118E3200508B2E1146C576B6@GGEXSF>, Tracy Pierce
><[log in to unmask]> writes
>>I have a recursive subpgm which must write to a file that's passed to it,
so
>>voila, EXTERNAL or GLOBAL seems to be the ticket. I'm doing everything
just
>>like the example provided in the COBOL manual (p 11-7 & 11-8) EXCEPT that
my
>>subpgm resides in an XL, not in the same program file as its caller.
so per Ken Hirsh's suggestion, I added ;SHARE to each of ADDXL and LINK for
main & sub; voila it works...well, almost. It works as long as the
recursion depth is < 2, but at the point at which the subpgm calls itself,
we die again when trying to write to the EXTERNAL file (FSERR 48 - file not
opened for sequential writes).
The practical solution seems to be write a separate subprogram to handle
writing the output (Thanks, Roy Brown!), but of course I'm trying to avoid
that; it seems that this EXTERNAL scheme SHOULD work.
Does anybody have EXTERNAL working to share an output file? I wonder what's
missing now?
MAIN:
open output EXTERN
Write first EXTERN
call sub
SUB: write EXTERN
SUB: call sub
SUB:SUB: write EXTERN (fails).
Tracy Pierce
>
> Hi Tracy
>
> Faced with the same issue, we take a different approach.
>
> We write a 'real' SUBPROGRAM (I hope your recursive subpgm is
> DYNAMIC!)
> to handle the file open, read/write and close, and CALL this, as
> required from the recursive subpgm.
>
> This gets round the restrictions that COBOL imposes on file
> handling in
> these circumstances.
>
> I don't know whether this is more or less neat, and/or more or less
> general, than a solution using EXTERNAL or GLOBAL though....
> --
> Roy Brown Kelmscott Ltd
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|