Progress
Language Tutorial
for Windows


Programming Example

Follow these steps to view the enhanced menu:

  1. Open lt-11-02.p and run it. The display shown below appears:
  2. Display the Reports pull-down menu. The third and fourth items are disabled, so you can’t choose them.
  3. Choose Mailing Labels. The mailing label frame appears.
  4. Choose Output to Printer from the Reports menu.
  5. Choose Mailing Labels again. An alert box appears informing you that the report printed. Choose OK to dismiss the alert box.
  6. Browse through the various submenus. Notice that a letter in each submenu or menu item is underlined. The underlined letter is a mnemonic.
  7. Choose Tables Exit, then press SPACEBAR to return to the Procedure Editor.

Following is the code for the enhanced version of the procedure:

lt-11-02.p
      /**********  DEFINE WIDGETS  **********/
      {lt-11-mn.i} /* Menu definitions */   
      DEFINE VARIABLE Rep-Editor AS CHARACTER VIEW-AS EDITOR 
          SCROLLBAR-VERTICAL SIZE 76 BY 13 .
      DEFINE VARIABLE Stat AS LOGICAL.

          /**********  DEFINE FRAMES  **********/
      DEFINE FRAME Frame1
          Rep-Editor WITH NO-LABELS ROW 2 CENTERED TITLE "Report Output"

          /**********  DEFINE TRIGGERS  **********/
      ON CHOOSE OF MENU-ITEM mi-Exit 
          APPLY "CLOSE-WINDOW" TO DEFAULT-WINDOW. 
      ON CHOOSE OF MENU-ITEM mi-Labels IN MENU sm-Reports
          RUN p-Report.

          /**********  MAIN LOGIC  **********/
      ASSIGN Rep-Editor:READ-ONLY IN FRAME Frame1 = YES
             Rep-Editor:FONT = 3.
      ENABLE ALL WITH FRAME Frame1.
      WAIT-FOR CHOOSE OF MENU-ITEM mi-Exit.

          /**********  INTERNAL PROCEDURES  **********/
      PROCEDURE p-Report: 
/*1*/  IF MENU-ITEM mi-Print:CHECKED IN MENU mbar = NO THEN 
           OUTPUT TO "tut-temp.txt". 
      ELSE OUTPUT TO PRINTER. 
                           
      FOR EACH Customer FIELDS (Balance Postal-Code Contact Name Address
          Address2 City St) WHERE Balance >= 1400 BY Postal-Code 
          WITH STREAM-IO:
          PUT Contact SKIP
              Name SKIP
              Address SKIP.     
          IF Address2 NE "" THEN PUT Address2 SKIP.    
          PUT City + "," + St + " " + STRING(Postal-Code, "99999")
              FORMAT "x(23)" SKIP(1).
          IF Address2 EQ "" THEN PUT SKIP(1).
      END. 
      OUTPUT CLOSE.
/*2*/  IF MENU-ITEM mi-Print:CHECKED IN MENU mbar = NO THEN 
        ASSIGN Stat = Rep-Editor:READ-FILE("tut-temp.txt") 
            IN FRAME Frame1.
      ELSE 
         MESSAGE "Report Printed" VIEW-AS ALERT-BOX MESSAGE BUTTONS OK.
      END PROCEDURE. 

These notes help explain the code:

  1. The CHECKED attribute applies only to toggle boxes and toggle box menu items. You can check it at any time to determine the on screen state of the menu item. If you wanted to write a trigger for the toggle box menu item, you would normally use the VALUE-CHANGED event function.
  2. Here, the CHECKED attribute determines whether to read the report output file into the editor or to let the user know that the output went to the default printer.

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