Progress
Programming
Handbook
Sharing Streams Among Procedures
In some cases, you might want two or more procedures to share the same input or output streams. The following procedures,
p-sstrm.p
andp-dispho.p
, share the same output stream, phonelist. Notice that phonelist is defined as a shared stream in both procedures:
The
p-sstrm.p
procedure defines a NEW SHARED STREAM called phonelist. The procedure sends the output from the phonelist stream to a file calledphonefile
. The procedure also calls thep-dispho.p
procedure:
The
p-dispho.p
procedure defines the SHARED STREAM phonelist, and displays the information from that stream on the screen. (It is more efficient to place the FOR EACH and DISPLAY statements in thep-sstrm.p
procedure. They are in a separate procedure here to illustrate shared streams.)NOTE: You cannot define or access shared streams in a persistent procedure. If you do, Progress returns a run-time error when you create the persistent procedure. For more information, see the sections on persistent procedures in Block Properties."Sharing streams is much like sharing variables:
- You use a regular DEFINE STREAM statement to define a stream that is available only to the current procedure.
- To define a shared stream, you define the stream as NEW SHARED in the procedure that creates the stream, and as SHARED in all other procedures that use that stream. If you do not explicitly close the stream, Progress closes it automatically at the end of the procedure in which you defined it.
- You define the stream as NEW GLOBAL when you want that stream to remain available even after the procedure that contains the DEFINE NEW GLOBAL SHARED STREAM statement ends.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |