Store EEP Files in the Database
 
     Using the VARBIT data type available in R:BASE 5.x, you can store EEP 
     files in the database itself. Use a single generic EEP file to write a 
     specific EEP from the database to a disk file and then execute the 
     EEP. The #FORM_FORMNAME, #FORM_TABLENAME, and #FORM_COLUMNNAME system 
     variables added in 5.0 make this easy to do.
 
     Create a table to hold the EEP data. For example, a table named 
     EEPTable might have the following columns:
 
     Column Name    Data Type  Description
     EEPid          INTEGER    An autonumbered ID column.
     FormName       TEXT 18    The name of the form the EEP is
                               used in. The form name is returned by 
                               the #FORM_FORMNAME system variable when 
                               the form runs.
     TableName      TEXT 18    The name of the table in the form
                               where the EEP is placed. The current table 
                               name is returned by the #FORM_TABLENAME 
                               system variable when the form runs.
     FieldName      TEXT 18    The name of the column or
                               variable the EEP is placed on.
                               The current field name is returned by the 
                               #FORM_COLUMNNAME system variable. For a 
                               table level EEP, use a key word indicating 
                               the type of table EEP: rowentry, saverow, 
                               exitrow, or exitsect. For an EEP placed on 
                               a button (5.1), use a keyword identifying 
                               the button: button1, button2, etc.
     EEP_Type       TEXT 18    The type of EEP: field, table, or
                               button.
     Descr          NOTE       A description of the EEP.
     EEP_File_Name  TEXT 12    The actual file name of the EEP.
     EEP_Data       LONG       The EEP command file.
                    VARBIT
 
     The table EEPTable can be loaded through a form, the Data Browser, or 
     the INSERT or LOAD commands. The easiest way to load the data would 
     be through a quick form. You can even have a form open in the Form 
     Designer while you are entering the information about that form in 
     the EEPTable form. Use the MDI syntax from the R> prompt window to 
     open the EEPTable form as a window. Then as you are entering data 
     about the EEPs, you can refer to the form in the Form Designer window 
     and make sure all the form, table, and column name references are 
     correct. Multiple windows open on the screen makes loading the table 
     with all the EEP information a fairly simple process.
 
     When entering the actual EEP file in the form, just press 
     [Shift][F10] from the EEP_data field. The Windows common file dialog 
     box opens and you can select the EEP file name directly. That file is 
     then loaded automatically into the table.
 
     Be aware that database File 4 can become quite large, particularly if 
     your database application has many EEPs. If most of the EEPs are 
     small files (< 4K), consider using a BITNOTE data type instead of 
     LONG VARBIT. The LONG VARBIT data type always allocates a minimum of 
     4K per row (file).
     The BITNOTE data type has a maximum length of 4K, and allocates only 
     as much space as it needs to store the file. You can use both a 
     BITNOTE column for small EEP files and a LONG VARBIT column for 
     larger files. Add code to the file generic.eep to determine which 
     column contains the EEP command file.
 
     Once the EEP files have been loaded into the table, the files can be 
     deleted from the hard disk.
 
     A single file, generic.eep, is used to run all the EEPs. Generic.eep 
     checks to see which form, table, and field is current when 
     generic.eep is called. The appropriate EEP code is written to a disk 
     file with a unique name and then that file is executed. For table and 
     button EEPs, parameters are passed from the form indicating the EEP 
     type and identifying name.
 
     Parameters can be passed to an EEP just as parameters can be passed 
     to a command file. A passed parameter becomes a percent variable. You 
     can only pass parameters to an ASCII EEP, not to an EEP that is a 
     block in a procedure file; there is not enough space on the settings 
     screens to enter block and procedure file names as well as parameter 
     values.
 
     The settings screens have two spaces available for naming the EEP 
     file. One space follows the word RUN and is used to enter the name of 
     the ASCII EEP file or command block; the second space follows the word 
     IN and is used to indicate the name of the procedure file when the EEP 
     is a command block. To pass parameters to an EEP, follow the name of 
     the ASCII EEP file with the keyword USING. Then, after the word IN, 
     place the desired parameter values. The word IN is passed as the first 
     parameter, %1, and the other parameters are numbered respectively. The 
     number of parameters is limited by the available space_18 characters.
 
     In generic.eep, the EEP type (field, table, or button) is passed as 
     parameter one (%2), and the second parameter (%3) identifies a 
     particular table or button EEP. The second parameter is compared to 
     the column FieldName in EEPTable. The parameter passing allows easy 
     checking and identification for table and button EEPs since they 
     aren't associated with a particular column.
 
     When assigning generic.eep to a button, for example, the "EEP Action" 
     dialog box looks like this:
 
     *(generic.eep)
     SET VAR vEEP_Type = .%2
     SET VAR vEEP_fieldname = .%3
     IF vEEP_Type = 'table' OR  +
     vEEP_Type = 'button' THEN
       SELECT EEP_Data INTO vEEP_Data FROM EEPTable +
         WHERE formname = .#FORM_FORMNAME AND +
         tablename = .#FORM_TABLENAME AND +
         fieldname = .vEEP_fieldname
     ELSE
       SELECT EEP_Data INTO vEEP_Data FROM EEPTable +
         WHERE formname = .#FORM_FORMNAME AND +
         tablename = .#FORM_TABLENAME AND +
         fieldname = .#FORM_COLUMNNAME
     ENDIF
     -- create a unique file name using the keyword NAME
     SET VAR vfile = (SGET(CVAL('NAME'),8,1)+ '.eep')
     WRITE .vEEP_Data TO .vfile
     RUN &vfile
     ERASE .vfile
     CLE VAR %1-0,%2-0,%3-0,veep_type, veep_fieldname
     RETURN