Progress
Language Tutorial
for Windows


Directing Output to a File

To direct output to a file, use the OUTPUT TO statement followed by the name of the destination file enclosed in quotes. The destination can include the path, or just the filename. If you do not provide a path, Progress writes the file to the current directory. If the file does not exist, Progress creates it. If the file does exist, Progress overwrites its contents.

The following code example is simply the report from the last exercise, removed from the interface code:

lt-10-09.p
/*1*/  OUTPUT TO "tut-temp.txt".
      FOR EACH Customer FIELDS (Balance Credit-Limit Name Contact Cust-Num)
          WHERE Balance >= (Credit-Limit * .85)
          WITH STREAM-IO:
          DISPLAY Name FORMAT "x(20)" Contact FORMAT "x(15)" 
              Balance Credit-Limit WITH NO-BOX STREAM-IO.
                
          FOR EACH Order FIELDS (Cust-Num Order-Num Order-Date Ship-Date
              Promise-Date) WHERE Order.Cust-Num = Customer.Cust-Num
                WITH STREAM-IO:
               DISPLAY Order-Num Order-Date Ship-Date 
                  Promise-Date SKIP(1) WITH 2 COLUMNS STREAM-IO.
                    
              FOR EACH Order-Line FIELDS (Order-Num Item-Num Qty)
                  WHERE Order-Line.Order-Num =
                  Order.Order-Num WITH STREAM-IO:
                 FIND Item WHERE Item.Item-Num = Order-Line.Item-Num.
                  DISPLAY Qty Order-Line.Item-Num 
                      Item-Name FORMAT "x(13)"
                      Item.Price LABEL "Unit Price"
                      Item.Price * Qty (TOTAL) 
                          LABEL "Price" FORMAT "$zzz,zz9.99 CR" 
                         WITH NO-BOX STREAM-IO.
              END.
          END.
       END.    
/*2*/  OUTPUT CLOSE. 

You can see from the highlighted points that the OUTPUT TO and OUTPUT CLOSE statements control the stream. Also note that the STREAM-IO option must appear in each output frame phrase.

Try running lt-10-09.p and then opening tut-temp.txt in the procedure editor; as you can see from the figure below, the content of the file matches what the interface showed in the last exercise:


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