Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Designing an interface for viewing report data

> In contrast to the Progress-controlled interface you saw in the last example, here’s what you need to create a user-controlled report viewing interface:

> 1. A dialog box to contain the output. Therefore, you won’t need to leave room on your main display for the report data.

> 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 to read the file into. The scrollbars let the user navigate the report in two directions.

> 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. Choose Report. The following report dialog box appears:

> The report data appears in an editor that you can scroll through.

> 3. Choose OK to dismiss the dialog box.

> 4. Choose 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 Bal-due AS LOGICAL LABEL "Balance Due?"
>               VIEW-AS TOGGLE-BOX.
>     /*1*/  DEFINE VARIABLE Rep-Editor AS CHARACTER VIEW-AS EDITOR
>               SCROLLBAR-VERTICAL SIZE 79 BY 16.
>           DEFINE VARIABLE Stat AS LOGICAL.
>           DEFINE BUTTON b-rep LABEL "Report".
>           DEFINE BUTTON b-exit LABEL "Exit".
>           DEFINE BUTTON b-ok LABEL "OK" AUTO-GO.
>           /**********  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 FIELDS (Balance Name) WITH STREAM-IO:
>                 IF Balance > 0 THEN Bal-due = YES.
>                 ELSE Bal-due = NO.
>                 DISPLAY Name Bal-due.
>                 END.
>     /*4*/      OUTPUT CLOSE.
>     /*5*/      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.
>     /*6*/      IF Stat 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 this example:

> 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 Progress successfully read the file contents into the editor.

> 6. You only want to bring up the dialog box if the logical variable stat equals `YES`, which means that Progress 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 Progress 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.

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