Progress
Language Tutorial
for Character


Formatting Long Text Strings

The remaining problem for simple output is how to handle long text strings. A text widget that contains a long string may cause formatting problems such as skipping to a new line or truncating. For screen design, you saw earlier that the editor widget is a good choice for holding long text strings. The editor is also the solution for reports. With the editor, you can output text in blocks.

For example, the Comments field in the Customer table has a format of x(60). Reserving 60 spaces takes up most of a line in a standard printed report. You can override this default behavior by specifying a VIEW-AS EDITOR phrase for the Comments field. When you output a field or variable value as an editor widget, Progress uses the INNER-CHARS attribute of the editor to format and wrap the text into a block. The INNER-LINES syntax sets the minimum number of lines the block occupies. If there is enough data to fill more lines than specified by INNER-LINES, then Progress provides the extra room.

The following exercise demonstrates editor output in reports:

  1. Open lt-10-04.p and run it.
  2. Choose Report. The report dialog box appears as shown in the following screen:
  3. As you scroll through the editor, notice the blocks of Comments text.

  4. Choose OK, then Exit, and then press SPACEBAR to return to the Procedure Editor.

Here is the code:

lt-10-04.p
    {lt-10-in.i} /* Common Interface Setup Code */  
 
    /**********  DEFINE TRIGGERS  **********/
    ON CHOOSE of b-rep
    DO:  
        OUTPUT TO "tut-temp.txt".
        FOR EACH Customer WITH STREAM-IO:
            DISPLAY Name SPACE(5) Comments VIEW-AS EDITOR 
/*1*/            INNER-LINES 3 INNER-CHARS 20.
        END.
        OUTPUT CLOSE.
    
        ASSIGN Rep-Editor:READ-ONLY IN FRAME Dialog1 = YES
             Rep-Editor:SENSITIVE IN FRAME Dialog1 = YES 
             FRAME Dialog1:TITLE = "Report Output"
             Stat = Rep-Editor:READ-FILE("tut-temp.txt") IN FRAME Dialog1.
         
        IF Stat THEN DO:
            ENABLE Rep-Editor b-ok WITH FRAME Dialog1.
            WAIT-FOR GO OF FRAME Dialog1.
            HIDE FRAME Dialog1.
        END.
    END. 
    /**********  MAIN LOGIC  **********/
    ENABLE ALL WITH FRAME Frame1.
    WAIT-FOR CHOOSE OF b-exit. 

INNER-LINES reserves at least three lines per iteration of the report. INNER-CHARS sets the length of the text block at 25 characters.

INNER-LINES reserves at least three lines per iteration of the report. INNER-CHARS sets the length of the text block at 20 characters.

This section concludes the basic discussion on creating a reporting procedure. The next few sections concentrate on the techniques for populating reports with more complex data.


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