Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Directing output to multiple destinations

> Progress lets you specify multiple output destinations in a single procedure. You can use `OUTPUT TO` several times in a single procedure to direct the output to different destinations. You can also define named streams so you can output to several destinations.

> First, you use the`DEFINE STREAM` statement to create the streams you need. This is a partial syntax for `DEFINE STREAM`:

> Syntax
>     DEFINE STREAM stream-name

> To output to the stream, you reference it in your output statement with the keyword `STREAM`, as shown in the following example:

>     /*1*/  DEFINE STREAM To-File.

>     /*2*/  OUTPUT TO PRINTER.
>     /*3*/  OUTPUT STREAM To-File TO "tut-temp.txt".

>           FOR EACH Customer FIELDS (Name Balance):
>     /*4*/    DISPLAY Name Balance WITH STREAM-IO.
>     /*5*/    DISPLAY STREAM To-File Name Balance WITH STREAM-IO.
>            END.

>     /*6*/  OUTPUT CLOSE.
>     /*7*/  OUTPUT STREAM To-File CLOSE.

> The notes below describe how the code works:

> 1. When the procedure starts, it has a default unnamed stream that outputs to the screen by default. This statement establishes a second stream that also outputs to the screen by default. Both streams are now available for the life of the procedure.

> 2. This `OUTPUT TO` statement redirects the unnamed stream to the default printer.

> 3. This `OUTPUT TO` statement redirects the named stream to output to a file.

> 4. The first `DISPLAY` statement outputs to the unnamed stream only.

> 5. The second `DISPLAY` statement outputs to the named stream only.

> 6. This `OUTPUT CLOSE` statement redirects the default stream back to the screen.

> 7. This `OUTPUT` `CLOSE` statement redirects the named stream back to the screen.

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