Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Creating Reports : Converting widget values to report data : Formatting long text strings
 
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, the AVM 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 the AVM provides the extra room.
To see an example of editor output in reports:
1. Open i-10-04.p and run it.
2. Click Report. The Report Output dialog box appears:
As you scroll through the editor, notice the blocks of Comments text.
3. Click OK, then Exit, and then press SPACEBAR to return to the Procedure Editor.
Here is the code for this procedure:
i-10-04.p
/* {i-10-in.i} Common Interface Setup Code */

/********** DEFINE TRIGGERS **********/
ON CHOOSE of b-rep DO:
  OUTPUT TO "tut-temp.txt".
  FOR EACH Customer NO-LOCK WITH STREAM-IO:
    DISPLAY Customer.Name SPACE(5) Customer.Comments
      VIEW-AS EDITOR INNER-LINES 3 INNER-CHARS 20.
  END.
  OUTPUT CLOSE.

  ASSIGN
    Rep-Editor:READ-ONLY IN FRAME Dialog1 = TRUE
    Rep-Editor:SENSITIVE IN FRAME Dialog1 = TRUE
    FRAME Dialog1:TITLE                   = "Report Output"
    lStat = Rep-Editor:READ-FILE("tut-temp.txt") IN FRAME Dialog1.

  IF lStat 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 completes the basic discussion on creating a reporting procedure. The next few sections concentrate on the techniques for populating reports with more complex data.