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:
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
Return to the map editor by entering the following.
EDIT MAP01
Use the arrow keys to select the input field for the starting name. Press ESC to redisplay the menu and choose .
The Extended Field Editing window appears.
+-Extended Field Editing-------------------------------------------------------+ ¦Field : #NAME-START ¦ ¦Format: A Len: 20 AL: 20 PM: ZP: N SG: N ¦ ¦Rules : 0 Rule Editing: N Array: None Array Editing: N Mode: User ¦ ¦AD: ILMFHT'_' CD: CV: DY: N HE: N ¦ ¦EM: ¦ +------------------------------------------------------------------------------+ |
Use TAB to move to the field Rule Editing. Either enter "Y" in this field or press PF2.
The following screen appears.
+-Current Field: #NAME-START---------------------------------------------------+ ¦ R U L E E D I T I N G (Esc = Quit) ¦ ¦Rules Fields ¦ +------------------------------------------------------------------------------+ End XXXXXXXXXXXXXXXXXXXX Create or modify a rule for this field |
Choose
and then .An empty editor window appears.
Enter the following processing rule (use
the line command I
to insert blank
lines):
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.
Enter the following in the command line:
P=1
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.
EDIT: S 02- ---------------Columns 001 074 Rank: NEW RULE Rule: Typ: R Mode: S Cmnd=> p=1 Scroll==> CSR ****** ******************************* top of data ***************************** 000001 IF & = ' ' THEN 000002 REINPUT 'PLEASE ENTER A STARTING NAME.' 000003 MARK *& 000004 END-IF ****** ***************************** bottom of data **************************** PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12-- P U End P* Rfind Rchng Up Down Right Left Home |
Press ENTER to save your input.
The following screen appears again. Your new rule with the rank 1 is now shown below
. When you select this rule, the first lines of your code are shown at the bottom of the screen.+-Current Field: #NAME-START---------------------------------------------------+ ¦ R U L E E D I T I N G (Esc = Quit) ¦ ¦Rules Fields ¦ +--------+---------------------------------------------------------------------+ ¦<CREATE>¦ ¦ 1¦ End XXXXXXXXXXXXXXXXXXXX +--------+ 0010 IF & = ' ' THEN 0020 REINPUT 'PLEASE ENTER A STARTING NAME.' 0030 MARK *& Create or modify a rule for this field |
Press ESC repeatedly until the Natural Map Editor menu is shown again.
Test the map.
In the resulting output, enter any starting name and press ENTER.
The output screen is closed.
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.
To leave the output screen, enter a dot (.) in the field which prompts for a starting name and press ENTER.
Stow the map.
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
From the Natural Map Editor menu, choose
.Natural's main menu is shown again with the Direct Command window prompting for input.
Enter one of the following:
EDIT PROGRAM
E P
An empty editor appears.
Enter the following:
WRITE 'Type the name of an employee' END
Change the program to a helproutine by entering the following in the program editor's command line:
SET TYPE H
where "H" denotes helproutine.
Stow the helproutine and name it
HLP01
.
STOW HLP01
To associate the helproutine with a field on the map
Return to the map editor by entering the following in the command line of the screen in which you have just entered the helproutine.
E MAP01
Select the data field for the starting name, press ESC to display the Natural Map Editor menu and choose .
The Extended Field Editing window is displayed for the field.
Use TAB to move to the field HE. Either enter "Y" in this field or press PF2.
A window appears prompting for the name of the helproutine.
In the HE field enter "'HLP01'" (including the single quotation marks).
This is the name under which you have saved your helproutine.
XXXXXXXXXX TT:TT:TT Start XXXXXXXXXXXXXXXXXXXX End XXXXXXXXXXXXXXXXXXXX +-HE-----------------------------------------------------------------+ ¦HE: 'HLP01' ¦ ¦ ¦ +--------------------------------------------------------------------+ +-Extended Field Editing-------------------------------------------------------+ ¦Field : #NAME-START ¦ ¦Format: A Len: 20 AL: 20 PM: ZP: N SG: N ¦ ¦Rules : 1 Rule Editing: Y Array: None Array Editing: N Mode: User ¦ ¦AD: MILFHT'_' CD: CV: DY: N HE: Y ¦ ¦EM: ¦ +------------------------------------------------------------------------------+ Helproutine and Parameters |
Press ENTER twice to save your changes and close all windows.
Test the map.
In the resulting output, enter a question mark (?) in the input field for the starting name.
The help text you have defined is shown.
Press ENTER to return to the map.
To leave the map, enter a dot (.) in the field which prompts for a starting name and press ENTER.
Stow the map.
From the Natural Map Editor menu, choose
.Natural's main menu is shown again with the Direct Command window prompting for input.
You can now proceed with the next exercises: Local Data Areas.