Assigning Actions to Menu Options |
Once you define a menu option, you can assign an action to it. An action is a command that performs a specific function. For example, the action for the menu option "View customer information" selects customer information from a table and displays it.
You can assign any number of actions (discussed below) to a single menu option. For example, you might want a user to be able to enter data in a table, view the data that was entered, correct any errors, and then print the data. To accomplish this, you must assign three actions to one menu option-"Enter data using a form," "Browse and edit rows in a table," and "Print reports." The Application Designer limits each application to 100 actions, regardless of their distribution in menu options.
When the user chooses an option that has more than one action assigned to it, the application executes each action in turn. When one action finishes, the application immediately executes the next action. When the last action finishes, the application returns to the menu that contains the option, just like a single-action option.
You can assign the following types of actions to menu options:
You can specify conditions for this option, or you can provide a prompt for the user to specify conditions. If you provide conditions, R:BASE automatically deletes any row that satisfies them. If you prompt the user for conditions, the user must complete the condition before R:BASE deletes a row.
When you define a custom action, the R:BASE text editor starts in the "RBEdit" window, where you can enter your code. You can also open an existing file so that you can use it in the application. End your code with the RETURN command. After you finish building the application, R:BASE adds your custom code to the application file as a command block.
For example, you could create a custom menu option that allows the user to total all bonuses paid to employees whole sales exceeded $125,000. The following code would be used:
CLS
CROSSTAB SUM (bonus) FOR netamount BY empid FROM +
salesbonus WHERE netamount > 125000
PAUSE 1 using 'Press any key to continue...'
CLS
RETURN
The CLS command clears the existing application screen of any text. CROSSTAB tabulates the bonuses paid to those employees who made sales totaling more than $125,000 and displays the bonus amounts, sale amounts, and totals. PAUSE suspends the processing of the code until the user responds by pressing a key. CLS clears the data from the screen. RETURN returns control to the menu.
You can also run other applications within an application. For example, to run a telephone directory application within your application, you can create a custom action. Enter a command file that includes the RUN command, such as the following:
RUN app IN app2.apx
RETURN
When the user chooses this menu option, your application runs the secondary application and displays its menus. When the user exits the secondary application, control is returned to your application.
You can insert an external command file in the application as well; from the "RBEdit" window, choose File: Open and select the command file to insert. Once the command file has been added to the application, you must edit it through the application.
Note: If you design a secondary application using the Application Designer, the secondary application uses the same internal global variables as the application that calls it. If you don't want to inadvertently clear the variables from the first application when you run the secondary application, you might want to save the variables before running the secondary application, then redefine them when the secondary application has completed.
For example, you can assign a user identifier to the menu option, assign the action that accesses the table, then assign a third action to reset the user identifier to public.
The following table lists the type of permission needed for each menu action.
| Menu Action | Permission Needed |
| Enter data using a form | INSERT/SELECT |
| Edit data using a form | UPDATE/SELECT |
| Delete rows from a table | DELETE |
| Browse and edit rows in a table | UPDATE/SELECT |
| Select rows from a table | SELECT |
| Update a column in a table | UPDATE |
| Print reports | SELECT |
| Print labels | SELECT |
You can also prompt the user for an identifier; only users with the correct identifier can then access the menu option. You can specify this prompt when you define this menu action.
For many of the menu actions, you can enter a WHERE clause to specify the data to display and the order to sort the data. You can also enter a WHERE clause with the "@" symbol to prompt the user for information.
For example, you might want to display data for a customer, and ask the user for the customer ID number by prompting "Enter the customer number." You could enter the following WHERE clause:
WHERE custid = @'Enter the customer number'
To assign an action to a menu option:
The "Menu Item Actions" Dialog Box
| If you selected... | Do the following... |
| Enter data using a form | In the "Action Definition" dialog box, select a form. |
| Edit data using a form | In the "Action Definition" dialog box, select a form, and optionally enter a WHERE clause to specify the data to display. |
| Delete rows from a table | In the "Action Definition" dialog box, select a table, and optionally enter a WHERE clause to specify the data to delete. |
| Browse and edit rows in a table | In the "Action Definition" dialog box, select a table, specify the column(s), and optionally enter a WHERE clause to specify the data to display. |
| Select rows from a table | In the "Action Definition" dialog box, select a table, specify the column(s), and optionally enter a WHERE clause to specify the data to display. |
| Update a column in a table | In the "Action Definition" dialog box, select a table, specify the column, enter a value to insert, and optionally enter a WHERE clause to specify the data to modify. |
| Print reports | In the "Action Definition" dialog box, select a report, and optionally enter a WHERE clause to specify the data to print. |
| Print labels | In the "Action Definition" dialog box, select a label, and optionally enter a WHERE clause to specify the data to print. |
| Custom actions | In the "Message" dialog box, enter the name for the command block and click the OK button. In the "RBEdit" window, enter your code for this custom action or open an existing file to use. When you have finished, choose File: Save, then choose File: Close. |
| Set user identifier | In the "Message" dialog box, enter the user identifier. (If you want to prompt the user for the identifier, do not enter anything.) |
Repeat Steps 2, 3, and 4 for each action you want to assign to this menu option.