Progress
Programming
Handbook
Sending Output to Multiple Destinations
At some points in a procedure, you might want to send output to the terminal, but at other points you might want to send output to a file. Progress does not restrict you to one output destination per procedure.
p-chgot2.pFigure 7–3: Multiple Output Destinations
![]()
In the procedure in Figure 7–3, you supply the name of the file where you want to send a customer report and then, if that file does not already exist, send the report to that file.
Here are the specific steps the procedure takes:
- The SET statement prompts you for the filename.
- The SEARCH function searches for the file, returning the filename if the file is found.
- If the file is found, the procedure:
- If the file is not found, the procedure uses this statement:
This statement redirects the output to the file you specified. You must use the VALUE keyword with the OUTPUT TO statement. The VALUE option tells Progress to use the value of the outfile variable rather than the name “outfile” itself. If instead you say OUTPUT TO outfile, Progress assumes that outfile is the name of the text file to which you want to send output.
You use the OUTPUT CLOSE statement to stop sending output to a destination. Output sent after the OUTPUT CLOSE statement goes to the destination used prior to the OUTPUT TO statement.
For example, the procedure in Figure 7–4 uses the OUTPUT CLOSE statement to reset the output destination from a file to the terminal.
p-out.pFigure 7–4: The OUTPUT CLOSE Statement
![]()
This procedure sends customer information to a file called
cust.dat
. Then the procedure displays the word “Finished” on your terminal screen. The specific steps in the procedure are as follows:
- The OUTPUT TO statement redirects output so all statements that normally send output to the terminal send output to the
cust.dat
file.- The FOR EACH customer and DISPLAY statements produce a report listing each customer’s name, address, city, and state. The procedure sends the report to the
cust.dat
file.- The OUTPUT CLOSE statement resets the output destination for the procedure from the
cust.dat
file to the terminal.- The last DISPLAY statement displays the message “Finished” on the terminal screen.
If the output destination prior to execution of
p-out.p
was the printer (or any destination other than the terminal), you must explicitly set the output destination to the terminal between Steps 3 and 4 using the OUTPUT TO statement with the TERMINAL option. Otherwise the OUTPUT CLOSE statement resets the output destination to the printer (or other prior destination).
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |