TOPIC: EDIT STATEMENTS [ USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide ] MPE/iX 5.0 Documentation
USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide
TOPIC: EDIT STATEMENTS
The next step in designing this form is to specify full field edits using
edit statements, which are part of the FORMSPEC Processing Specifications
language. Edit statements enable you to specify more precise field edits
than the simple edits you specified in Section 2. Before you specify
full edits in the exercise, read the following brief description of the
edit statements available with FORMSPEC.
Types of Statements
Edit statements consist of statement names followed by parameters, which
are values or patterns that you specify. You also have the option of
specifying an error message for each edit statement to be used if the
field fails the test. Following are descriptions of the edits available.
Minimum Length. The value entered must be at least a specified number of
characters long. For example: MINLEN 10 means at least ten characters
must be entered in the field.
Single Value Comparison. Single value comparisons are a set of edit
statements, shown in Table 4-1, that compare the value entered in the
current field (the field whose Field Menu has the edit statement) with a
value specified in the statement. The value to which the entered data is
compared must always be the same data type as the field (character,
numeric, or date). Depending on which of the statement names you use,
the value entered must be equal to, equal to or greater than, equal to or
less than, less than, greater than, or not equal to a specified value.
For example: GE FIELD2 means the value entered in the current field must
be equal to or greater than the value entered in a different field,
FIELD2.
Table 4-1. Comparison Editing Statements
---------------------------------------------------------------------------------------------
| | |
| Statement | Meaning |
| | |
---------------------------------------------------------------------------------------------
| | |
| EQ | is equal to |
| | |
| NE | is not equal to |
| | |
| LT | is less than |
| | |
| GT | is greater than |
| | |
| LE | is less than or equal to |
| | |
| GE | is greater than or equal to |
| | |
---------------------------------------------------------------------------------------------
Range Check. Another type of edit statement specifies a range of values
within which the entered value must fall. A range statement consists of
IN (is in) or NIN (is not in) followed by a range of values. The first
value in the range is separated from the last by a colon (:). The first
value must be the lower value.
Possible range checks are:
IN "AAMES":"AZIMOV" Only names between AAMES and AZIMOV
(inclusive) are acceptable in a character
type field.
IN $TODAY: !12/31/86! Only dates between today's date through 1986
can be entered.
NIN 20:50 Values between 20 and 50 are treated as
errors. (Note that this statement indicates
a range of unacceptable values.)
IN 10:20, F1:F4, 100:300 Means the value must be between 10 and 20,
or between the values entered in fields F1
and F4, or between 100 and 300, inclusive.
Table Check. A special case of the range check is a table (or list)
check. This edit determines whether the entered value is one of a set of
values arranged as a table or list. Like the range check, the table
check statement starts with either IN (is in) or NIN (is not in). Unlike
a range check, every value in the table must be listed and separated by
commas. For example, consider the following table checks:
IN 2,4,6,8,10,12,14,16,20 Entered value must be one of the specified
values.
IN 5,10,15,F7+5 Means the value must be 5, 10, 15 or the
current value of field F7 plus 5.
Pattern Check. Another edit statement checks an entered value against a
pattern, which indicates the type of character that can be entered as
well as the exact character. The key word MATCH indicates that the value
is to be matched against the pattern. For example, you can specify that
a value start with any uppercase letter followed by three digits, a
hyphen, and two more digits with the following pattern:
MATCH uddd-dd Allows A123-56 or C009-10 and so forth.
A description of the special characters allowed in a MATCH statement will
be presented later in this section.
Check Digit. In addition to the field edits discussed so far, there is
one other edit--you can test a value for a check digit.
Action
Refer to Section 4 and Appendix D of the VPLUS/V Reference Manual for a
complete discussion of what check digits are and how to add and test
them.
In this section, you add edit statements to the fields shown in Table 4-2
below.
Table 4-2. Edit Statements Added to ORDER Form
-----------------------------------------------------------------------------------------------
| | | |
| Field Name | Edit Statement | Meaning |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ORDATE | EQ $TODAY | Date must be today's date. |
| | | |
| ST | IN $STATE | Use legal state code only. |
| | | |
| ZIP | MATCH ddddd[-dddd] | Value must match format exactly, for |
| | | example: (408) 249-7020. |
| | | |
| QTY | GE 1 | Value must be greater than or equal to |
| | | 1. |
| | | |
| PARTNUM | MATCH Puddd-??? | Value must match format exactly, for |
| | | example: PA123-a57. |
| | | |
-----------------------------------------------------------------------------------------------
In order to help you become familiar with the use of NEXT and PREV, you
are to specify the edit statements according to the type of edit, not in
the order of the fields on the form.
Figure 4-4. The Field Menu for ORDATE in the ORDER Form
MPE/iX 5.0 Documentation