Progress
Language Reference


DEFINE STREAM Statement

Interfaces
OS
SpeedScript
All
All
Yes

Use the DEFINE STREAM statement when you want to use streams other than the two unnamed streams supplied by Progress. Using other streams let you, in a single procedure, get input from more than one source simultaneously or send output to more than one destination simultaneously.

SYNTAX

DEFINE [ [ NEW [ GLOBAL ] ] SHARED ] STREAM stream 

NEW SHARED STREAM stream

Defines a stream that can be shared by other procedures. When the procedure using the DEFINE NEW SHARED STREAM statement ends, the stream is no longer available to any procedure. The value you use for the stream option must be a constant.

NEW GLOBAL SHARED STREAM stream

Defines a stream that can be shared by other procedures and that will remain available even after the procedure that contains the DEFINE NEW GLOBAL SHARED STREAM statement ends. The value you use for the stream option must be a constant.

SHARED STREAM stream

Defines a stream that was created by another procedure using the DEFINE NEW SHARED STREAM statement or the DEFINE NEW GLOBAL SHARED STREAM statement. The value you use for the stream option must be a constant.

STREAM stream

Defines a stream that can be used only by the procedure containing the DEFINE STREAM statement. The value you use for the stream option must be a constant.

EXAMPLES

This procedure, in a single pass through the item table, uses the rpt stream to create a report and the exceptions stream to create a list of exceptions.

r-dfstr.p
DEFINE NEW SHARED STREAM rpt.
DEFINE STREAM exceptions.
DEFINE VARIABLE fnr AS CHARACTER FORMAT "x(12)".
DEFINE VARIABLE fne AS CHARACTER FORMAT "x(12)".
DEFINE VARIABLE excount AS INTEGER LABEL "Total Number of exceptions".
DEFINE NEW SHARED BUFFER xitem FOR item.

SET fnr LABEL "Enter filename for report output" SKIP(1)
    fne LABEL "Enter filename for exception output"
    WITH SIDE-LABELS FRAME fnames.

OUTPUT STREAM rpt TO VALUE(fnr) PAGED.
OUTPUT STREAM exceptions TO VALUE(fne) PAGED.

FOR EACH xitem:
    IF on-hand < alloc THEN DO:
      DISPLAY STREAM exceptions item-num item-name on-hand alloc
         WITH FRAME exitem DOWN.
      excount = excount + 1.
    END.
    RUN r-dfstr2.p.
END.

DISPLAY STREAM exceptions SKIP(1) excount WITH FRAME exc SIDE-LABELS.
DISPLAY STREAM rpt WITH FRAME exc.

OUTPUT STREAM rpt CLOSE.
OUTPUT STREAM exceptions CLOSE. 

Include the DISPLAY statement in the r-dfstr2.p procedure in the r-dfstr.p procedure for efficiency. (It is in a separate procedure here to illustrate shared streams.)

r-dfstr2.p
DEFINE SHARED STREAM rpt.
DEFINE SHARED BUFFER xitem FOR item.

DISPLAY STREAM rpt item-num item-name WITH NO-LABELS NO-BOX. 

NOTES

SEE ALSO

DISPLAY Statement, INPUT CLOSE Statement, INPUT FROM Statement, INPUT THROUGH Statement, INPUT-OUTPUT THROUGH Statement, OUTPUT CLOSE Statement, OUTPUT THROUGH Statement, OUTPUT TO Statement, PROMPT-FOR Statement, RUN Statement, SEEK Function, SEEK Statement, SET Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095