Progress
Language Tutorial
for Windows
Using the PUT Statement
The PUT statement is another useful 4GL element for generating reports, especially when you want to customize certain parts of a report. The PUT statement has no default framing services, making it useful for writing data to a file or overriding default framing. Since PUT has no framing defaults, your procedures must contain explicit code for formatting your output.
The PUT statement outputs data one field at a time and uses the format of the field or variable. To include line breaks in the output, you must use the SKIP option. Additionally, the UNFORMATTED option of PUT displays all the data of the field or variable, regardless of format and without spaces between fields.
Why would you use PUT instead of DISPLAY? For every DISPLAY statement, Progress needs a frame. To execute a DISPLAY statement, Progress builds a frame capable of handling the expected output, using default services and your explicit instructions. PUT on the other hand, simply outputs data one line at a time, with no default formatting. DISPLAY is most useful when you want automatic formatting. PUT is most useful when you want complete control over output.
This is a partial syntax for the PUT statement.
One common task that the PUT statement can help with is mailing labels. Since mailing labels must conform to a compact physical layout and be uniform, using PUT is a good idea. Suppose that the All Around Sports accounting department wants to send notices to customers with large balances. They need a procedure that creates mailing labels for the notices.
Follow these steps to demonstrate the PUT statement:
Here is the code for this procedure:
This procedure contains the following points of interest:
To improve this procedure, you can:
If you run
lt-10-12.p
, you can see the modified version of this procedure. Here is the code for that version:
This is the output of the procedure:
![]()
The following notes help explain the techniques used in the procedure:
- The first PUT statement outputs and formats the part of the mailing label that is common to all labels.
- The first IF statement determines whether the second address line has data. If it does, it outputs the data.
- When you create a character expression, like the one in this PUT statement, Progress removes trailing blanks from the fields. So this output tightens up the extra white space that showed up in the first mailing list example.
- Finally, the second IF statement determines whether there is second address line data. If not, the PUT statement sends a blank line at the end of the address. This statement keeps the label data together and keeps the individual labels correctly spaced from each other.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |