Understanding the .APP File

When R:BASE creates application files, it translates the menus and actions you defined into R:BASE commands. R:BASE organizes the commands into command, menu, and screen blocks. A command block can execute commands and display menu and screen blocks.

The first command block in a procedure file defines the application--its environment, database, and menu processing. The first command block can be lengthy because it contains all the commands necessary to handle all menu processing for the application.

An application file lists the menu and screen blocks after the first command block, followed by other command blocks. If the application contains any command files installed with the Custom options, R:BASE writes each Macro or Custom action as a separate command block.

Command lines at the beginning of an application define environment settings and open the database. For an example, see "Sample of Beginning Command Lines" later in this section.

After the database environment has been set and the database opened, command lines in the .APP file create a main menu then process the choices users make from this menu. For a code example, see "Sample of Beginning Command Lines" below.

Sample of Beginning Command Lines

  1. $COMMAND
  2. concomp
  3. SET MESSAGES OFF
    CONNECT CONCOMP
    SET ERROR MESSAGES OFF
    SET COLOR WHITE ON BLUE
    SET BELL OFF
  1. The $COMMAND line identifies the commands that follow as a command block in the procedure file.
  2. The line following $COMMAND must always be the name of the command block. In this case, the first executed command block in a procedure file is the same as the name you assign to the application.
  3. This series of commands sets the environment, opens the database. The main processing taking place in a procedure file consists of checking the menu variables and then performing the actions you chose for the options.

Sample of Command Lines

  1. LABEL LBEG1
  2. NEWPAGE
    CHOOSE PICK1 FROM Main IN concomp.apx RED ON GRAY
  3. IF PICK1 = 0 THEN
    BREAK
    ENDIF
  4. SWITCH (.PICK1)
  5. CASE 1
    SET VAR LEVEL2 INT = 1
    WHILE LEVEL2 = 1 THEN
    NEWPAGE
    CHOOSE PICK2 FROM sales IN concomp.apx AT 2 6 +
    RED ON GRAY
    IF PICK2 = '[ESC]' THEN
    BREAK
    ENDIF
  6. SWITCH (.PICK2)
  7. CASE 'Enter/edit sales representatives'
    EDIT USI employee ORDER BY +
    emplname ASC,empfname ASC,empid ASC
    BREAK
  8. CASE 'Print reports'
    SET VAR LEVEL3 INT = 1
    WHILE LEVEL3 = 1 THEN
    NEWPAGE
    CHOOSE PICK3 FROM salesrep IN+
    concomp.apx BLACK ON CYAN
    IF PICK3 = '[ESC]' THEN
    BREAK
    ENDIF
    SWITCH (.PICK3)
    BREAK
    ENDSW
    ENDWHILE
    BREAK
    ENDSW
    ENDWHILE
    ENDSW
    LABEL lend1
  1. The LABEL command identifies the start of the processing section of the command file. Until you choose to exit by pressing [Esc] or choosing the Exit option from the menu, control returns to this label.
  2. The NEWPAGE command clears the screen, and the CHOOSE command displays the application's main menu and places the menu choice in the variable pick1. The menu being a vertical menu, the variable is an INTEGER data type value.
  3. This IF... ENDIF structure provides for [Esc] to allow you to leave the application. Pressing [Esc] passes control to LABEL lend1.
  4. The first SWITCH structure directs processing for the choices on the main menu.
  5. This CASE controls the action if you choose menu option 1. The CHOOSE command displays the menu for this option and places the menu choice in the variable pick2. The menu is a pop-up, so the data type of the value stored in the variable is TEXT. This outer WHILE loop ensures that the Sales menu is displayed until the user presses [Esc] or chooses the Exit option from this menu.
  6. This SWITCH structure controls processing for the choices on the menu for Sales representatives.
  7. If you choose the Enter/edit sales representatives option from the menu, R:BASE executes this EDIT command and, when the execution is completed, breaks out of the SWITCH structure to continue processing after the ENDSW for this SWITCH structure.
  8. If you choose the Print reports option from the menu, R:BASE displays a menu of print options and places the menu choice in the variable pick3. Since the menu is of row type, the variable has the TEXT data type. This inner WHILE loop ensures that the Sales representatives menu is displayed again after the report is printed and until the user presses [Esc] or chooses Exit from this menu.