Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Creating Reports : Designing an interface for viewing report data
 

Designing an interface for viewing report data

In contrast to the ABL-controlled interface you saw in the last example, you need the following to create a user-controlled report viewing interface:
1. A dialog box to contain the output, so report data does not require space on your main display.
2. An OK button in the dialog box to let the user dismiss the report.
3. A temporary file to contain the report data. Having the control block output to a temporary file eliminates the pausing behavior.
4. An editor widget with scrollbars for navigating the report.
The next example creates a dialog box interface for the same report you saw in the last example. The notes that follow the exercise explain the new code techniques you need to make this interface work.
To create a dialog box interface for the report in Windows:
1. Open i-10-02.p and run it. The following screen appears:
2. Click Report. The Report Output dialog box appears:
The report data appears in an editor that you can scroll through.
3. Click OK to dismiss the dialog box.
4. Click Exit and then press SPACEBAR to return to the Procedure Editor.
Here is the code for this example:
i-10-02.p
/********** DEFINE WIDGETS **********/
DEFINE VARIABLE lBalDue    AS LOGICAL   NO-UNDO LABEL "Balance Due?"
        VIEW-AS TOGGLE-BOX.
      DEFINE VARIABLE lStat      AS LOGICAL   NO-UNDO.
/*1*/ DEFINE VARIABLE Rep-Editor AS CHARACTER NO-UNDO VIEW-AS EDITOR
        SCROLLBAR-VERTICAL SIZE 79 BY 16.

      DEFINE BUTTON b-exit LABEL "Exit".
DEFINE BUTTON b-ok   LABEL "OK" AUTO-GO.
      DEFINE BUTTON b-rep  LABEL "Report".

/********** DEFINE FRAMES **********/
DEFINE FRAME Frame1
        SKIP(1)
        b-rep SKIP(1)
        b-exit
        WITH NO-BOX CENTERED THREE-D.
DEFINE FRAME Dialog1
        Rep-Editor SKIP(1)
        b-ok TO 40 SKIP(1)
        WITH NO-LABELS VIEW-AS DIALOG-BOX SCROLLABLE.

/********** DEFINE TRIGGERS **********/
ON CHOOSE of b-rep DO:
/*2*/   OUTPUT TO "tut-temp.txt".
/*3*/   FOR EACH Customer WITH STREAM-IO:
          lBalDue = IF Customer.Balance > 0 THEN TRUE ELSE FALSE.
          DISPLAY Customer.Name lBalDue.
        END.
/*4*/   OUTPUT CLOSE.
/*5*/   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.
/*6*/   IF lStat THEN DO:
          ENABLE Rep-Editor b-ok WITH FRAME Dialog1.
          WAIT-FOR GO OF FRAME Dialog1.
/*7*/     HIDE FRAME Dialog1.
        END.
END.

/********** MAIN LOGIC **********/
/*8*/ ASSIGN Rep-Editor:FONT = 3.
ENABLE ALL WITH FRAME Frame1.
WAIT-FOR CHOOSE OF b-exit.
These notes explain the new code techniques used in i-10-02.p:
1. This editor is for the report data.
2. The OUTPUT TO statement is your tool for directing output. This example directs output to the named file. This chapter covers directing output more fully in a later section.
3. This FOR EACH uses the default down frame, and the STREAM-IO option reduces all widgets to textual data without decorations. Using the STREAM-IO option is a requirement when outputting to any destination other than the screen.
4. Once you direct output to a destination, you need to close the output stream to return output to the default destination, which is the screen.
5. This ASSIGN statement manipulates three editor attributes and one method to set up the dialog box. The READ-ONLY attribute prevents changes to the report content. The SENSITIVE attribute enables the editor, making the scrolling functions available. The TITLE attribute contains the dialog box title text. The READ-FILE method takes a valid filename and returns YES or NO to indicate if the AVM successfully read the file contents into the editor.
6. You only want to bring up the dialog box if the logical variable lStat equals YES, which means that the AVM successfully read the file into the editor.
7. If you use a WAIT-FOR statement in a dialog box, you must use the HIDE statement to dismiss the dialog box.
8. On all platforms that OpenEdge® supports, the output font designated by 3 is always a monospaced font, which are frequently used in printed reports. Assigning this font makes the editor contents mimic a printed report.