DOCUMENT #778
     ===========================================================================
     AN ACTIONS TABLE FOR EEPS
     ===========================================================================
     PRODUCT:  R:BASE                           VERSION:  4.5+ or Higher
     ===========================================================================
     CATALOG:  Forms, Reports & Labels          AREA   :  Forms
     ===========================================================================
 
     A method that lends itself to a more dynamic environment is to create a 
     table which contains actions based on keystrokes used to leave a field. 
     This allows you to add more capability to the EEP without having to 
     constantly edit the EEP code. However, all of these actions that can be 
     performed in an EEP can become confusing if every field on the form has 
     multiple actions. Therefore it is best to consolidate all actions from your 
     form into one EEP from one "actions" field.
 
     Consolidating many actions into one EEP off one field.
 
     Create an "actions" field to which the user may go to execute a variety of
 
     actions. This can be done by defining a variable, for example, VActions = 
 
     (CTR('Actions',9)), then placing the variable somewhere on the form. Modify 
     the field characteristics to ensure that it is editable, then have an 
     ACTIONS.EEP for interrogating the LASTKEY and what actions should occur.
 
     Create a table that has a structure similar to the following.
 
     Column Name     Data Type       Length  Purpose
 
     MenuSays        TEXT    50      Menu text for action menu when hot        
              
                                     key is unknown.
     MenuDoes        TEXT    150     Full command line to execute
     CalledBy        TEXT    8       The form from which this action is        
              
                                     being called.
     HotKey  TEXT    8       Hotkey that calls this action while               
              on Action field.
     ClearScreen     TEXT    60      Clear screen command for form in form     
              use
 
     The MenuSays field provides menu text for a CHOOSE varname FROM #VALUES 
     command when the user is not familiar with the hotkeys enabled for a given
 
     form. 
 
     The MenuDoes field contains a command line to be executed based on the 
     hotkey pressed or particular menu item selected. 
 
     The CalledBy column is compared in your EEP with a variable set in your 
     form's expression list for table one, for example, VFormname = 'Customer'.
 
     The expressions places the form name into a variable. This allows you to 
     define actions for many different forms, as well has having your hotkeys 
     represent different actions when using different forms. 
 
     It is also possible to pass a table name to an EEP using a similar 
     expression, vtablename = 'tblname'. This expression is placed on each table 
     in the form referencing the appropriate tablename. An EEP that can be 
     called from many places on the form will know which table is active through 
     use of a form variable like this. 
 
     The ClearScreen field is used to store a CLS command that has the 
     appropriate dimensions of an area and color that you want to clear. The 
     presence of a value for the ClearScreen field is detected in the EEP and 
     the appropriate CLS command executed only when this field has a value.
 
     The clear screen command and the action command are executed using ampersand 
     variables. For more information about ampersand variables, refer to "Working 
     With Variables" in the Sept/Oct 1993 issue of the Exchange, FAX server 
     document #738.
 
     The type of actions that can be performed in MenuDoes is any single line 
     command, that is, you cannot have multiple commands concatenated into one 
 
     line with the use of the semicolon. For example:
 
     Acceptable command line
     EDIT USING Invoice WHERE CustId = .VCustId +
       ORDER BY InvoiceDate DESC AT 10
 
     Unacceptable command line
     INSERT INTO TABLE Invoice (CustId) +
       VALUES (.VCustId) ; EDIT USING NewInvc +
         WHERE CustId = .VCustId AND InvoiceDate IS NULL
 
     A command line executed using the & executes a 
     single command only. It does not work for multiple commands. If there is 
     more than one command line that needs to be executed for a particular 
     action, you must execute another command file. For example:
 
     RUN AddInvc.CMD USING .VInvoice
 
     The list of commands that you cannot execute while in an EEP includes the 
 
     following:
     CONNECT, DISCONNECT, ZIP (ROLLOUT, RETURN), QUIT, EXIT, GATEWAY, CODELOCK,
 
     as well as any of the commands normally utilized to create or modify tables, 
     forms, reports, or labels.
 
     Sample data from the Actions table:
 
     Below is a sample ACTIONS.EEP using this technique.
 
     *(ACTIONS.EEP)
     IF (LASTKEY(0)) <> '[F2]' OR +
        (LASTKEY(0)) NOT LIKE '[ALT]%' THEN
          RETURN
     ENDIF
 
     *( Trap for common ALT keys that invoke R:BASE form menus)
     IF (LASTKEY(0)) IN ('[ALT]A','[ALT]E','[ALT]G') THEN
          RETURN
     ENDIF
 
     *( If LASTKEY(1) was F2, display a menu of choices.  
        Notice the return value from the CHOOSE is HotKey 
        uses the new 4.5 Plus feature to return a column not
        displayed on the menu.)
 
     IF (LASTKEY(0)) = '[F2]' THEN
        IF (LASTKEY(1)) = '[F2]' THEN
           CHOOSE VHotKey FROM #VALUES FOR +
             ((LJS(MenuSays,50)) & HotKey), HotKey +
             FROM Actions WHERE CalledBy = .VFormName +
             ORDER BY MenuSays AT CENTER CENTER CLEAR
           ELSE
             SET V VHotKey = (LASTKEY(1))
          ENDIF
     ELSE 
          SET V VHotKey = (LASTKEY(0))
     ENDIF
 
 
     *( Now that the hot key and form is known, grab the rest of the row)
     SELECT MenuSays, MenuDoes, ClearScreen INTO +
          VMenuSays I1, VMenuDoes I2, VClearScreen I3 +
          FROM Actions WHERE CalledBy = .VFormName AND HotKey = .VHotKey
 
     *( Next, execute what we have retrieved.  
        First, clear screen if a value exists)
     -- checks the indicator variable, a 0 is returned 
     -- if a value was retrieved
     IF I3 = 0 THEN
          &VClearScreen
     ENDIF
 
     *( Use PAUSE 3 to let the user know what's about to happen)
     PAUSE 3 USING .VMenuSays AT CENTER CENTER WHITE ON CYAN
 
     &VMenuDoes
 
     *( You should take care to check for and handle errors accordingly)
 
     CLEAR VAR VMenuSays, VMenuDoes, VHotKey, VClearScreen, I%
     RETURN
 
     Again, using this technique where actions for hotkeys (or menu selections)
 
     are stored within an R:BASE table allows you to dynamically add to or 
     remove from the list without modifying the EEP code.