Processing Rules and Helproutines

#### Search Results

Search

# Processing Rules and Helproutines

Processing rules and helproutines are defined for fields in a map.

When you have completed the exercises below, your sample application will consist of the following modules (a processing rule cannot be defined as a separate module; it is always part of a map):

This document contains the following exercises:

- Defining a Processing Rule

- Defining a Helproutine

## Defining a Processing Rule

You will now define the message that is to be displayed when the user presses ENTER without specifying a starting name.

To define a processing rule

1. Return to the map editor.

2. Select the input field for the starting name.

3. From the context menu, choose Rules.

   The Field Rules dialog box for the field `#NAME-START` appears.

4. Choose the Create button.

   An empty editor window appears.

5. Enter the following processing rule:

       IF & = ' ' THEN
         REINPUT 'Please enter a starting name.'
         MARK *&
       END-IF

   The ampersand (&) in the processing rule will dynamically be replaced with the name of the field. In this case, it will be replaced with `#NAME-START`. If `#NAME-START` is blank, the message defined with the `REINPUT` statement is displayed.

   `MARK` is an option of the `REINPUT` statement. Its syntax is `MARK *fieldname`. `MARK` specifies the field in which the cursor is to be placed when the `REINPUT` statement is executed. In this case, the cursor will be placed in the `#NAME-START` field.

6. Save the content of the editor window.

   The Rule Selection dialog box appears.

7. In the Rank list box, select 1 and choose the OK button.

   The rank defines the sequence in which the rules for the different fields are to be processed. All rules with rank 1 are processed first, followed by those with rank 2, etc.

8. Close the editor window in which you have entered the processing rule.

9. Test the map.

10. In the resulting output, enter any starting name and press ENTER.

    The output window is closed.

11. Test the map once more. Do not enter a name and press ENTER.

    The message defined with the processing rule should now appear in the map.

12. To leave the output window, enter a dot (.) in the field which prompts for a starting name and press ENTER.

13. Stow the map.

## Defining a Helproutine

A helproutine is displayed when the user presses the help key when the cursor is on the input field for the starting name.

You will first define the helproutine and then associate it with a specific field.

To create a helproutine

1. In the library workspace, select the library which also contains your program (that is: select the TUTORIAL node).

2. From the context menu, choose New Source > Helproutine.

   An empty editor appears.

3. Enter the following:

       WRITE 'Type the name of an employee'
       END

4. Stow the helproutine.

   The Stow As dialog box appears.

5. Enter "HLP01" as the name of the helproutine.

6. Choose the OK button.

   In the library workspace, a new node named Helproutines appears below the TUTORIAL node. This node contains the helproutine you have just stowed.

7. Close the editor window in which you have entered the helproutine.

To associate the helproutine with a field on the map

1. Return to the map editor.

2. Select the data field for the starting name.

3. From the context menu, choose Definition.

   Or:
   Double-click the data field.

   The Field Definition dialog box appears.

4. In the Helproutine text box, enter "'HLP01'" (including the single quotation marks).

   This is the name under which you have saved your helproutine.

5. Choose the OK button.

6. Test the map.

7. In the resulting output, enter a question mark (?) in the input field for the starting name.

   The help text you have defined is shown in a separate window.

8. Press ENTER to close this window.

9. To leave the map, enter a dot (.) in the field which prompts for a starting name and press ENTER.

10. Stow the map.

11. Close the map editor window.

You can now proceed with the next exercises: Local Data Areas.

### On this page

- Defining a Processing Rule
- Defining a Helproutine