HPlogo HP Data Entry and Forms Management System (VPLUS) Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 Advanced Forms Design

Statement Syntax

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The processing specifications consist of statement names followed by parameters. The description of each statement uses the conventions defined at the beginning of the manual. In order to understand the notation used in the statement formats in this section, you should review these conventions.

Multiple statements can be placed on the same line by following the last parameter of the statement by a blank and the next statement. If you want, you can separate statements on the same line with an optional semicolon (;). For example:

MINLEN 5  GT 1000  LT 2500  3 statements without separator
MINLEN 5; GT 1000; LT 2500 3 statements separated by ;

Statements may begin anywhere on the line, except for nested IF statements where indentation is significant. Multiple blanks are ignored within a line, except at the beginning of a line in a nested IF statement.

Comments

Comments may be included in the text by preceding the comment with a backslash (\). Anything typed between the backslash and the end of the line is ignored. For example:

Continuing Lines

Statements that are not completed before the first backslash or the end of the line can be continued anywhere on the next line. A continuation character, the ampersand (&), is used only when a string literal must be continued on the next line. The ampersand concatenates two or more string literals to form one string. For example:

EQ "ABCDEF"&             \This field must be the string of
"UVWXYZ" \the uppercase letters ABCDEFUVWXYZ.

Custom Error Messages

Whenever a field edit statement detects an error at run-time, the application can call the appropriate VPLUS intrinsics to have an error message (provided by VPLUS) issued and displayed in the window line, such as is done with ENTRY. You may choose to write a custom message to be issued when a field fails a particular edit specification. To do this, you specify the custom message in quotes immediately following the statement to which it applies. Figure 4-1 “Field Menu with Processing Specifications” illustrates a Field Menu in which the processing specifications contain custom error messages. When and if the statement causes a field to fail, the custom message is displayed instead of a VPLUS error message. For example:

MATCH udddd       "Field has wrong format for Product Number"

Figure 4-2 Field Menu with Custom Error Messages

Field Menu with Custom Error Messages

Checking Data Entered

The field attributes for the field determine the first checks made on the data in the field. For example, if the field is required (FType=R), it is checked to be sure that the user has entered a value in the field. Editing is performed according to the data type. For example, if the data type is DIG, then the field is checked to be sure that only the digits 0-9 were entered in the field. Next, the processing specifications are tested in the order they are specified. As an example, consider the specifications in Figure 4-2 “Field Menu with Custom Error Messages” After making the checks based on the field attributes, data entered in the field is tested to be sure that at least 5 digits were entered (MATCH ddddd), and optionally the value is checked for a hyphen and 4 more digits ([ - dddd ]). In all cases, the checks are performed by VPLUS when the application calls the appropriate VPLUS intrinsics, as described in Section 6.

The following sections provide a summary of all the statements that may be entered in the Processing Specifications area of the Field Menu. Each of these statements is fully described later in this section.

CONFIGuration Statements

  LOCALEDITS [ALPHABETIC
ALPHANUMERIC
CONSTANT
IMP_DEC
IMP_DEC_FILL
INTEGER
INTEGER_FILL
SIGN_DEC
SIGN_DEC_FILL
UNRESTRICTED
UPSHIFT ] [JUSTIFY
MUST_FILL
REQUIRED] ...[DEC_DIGITS n]
[DEC_TYPE_EUR
DEC_TYPE_US ]
[TRANSMIT_ONLY]

LIGHT {@
A
...
O
P }...

DEVICE {PRINTER
KEYBOARD
MAGSTRIPE
TYPEV
MULTIFUNCTION
READER
MFR [CADMARKS
NONE HOLES
CAD HOLES [CUT
NOCUT]]
DISPLAY [LARGECHAR
STDCHAR]
BARCODE [READER] [UPC
I25
I39
MAT
EAN
IVL]}...

Edit Statements

    MINLEN value ["msg"]            {GT 
LT
GE
LE
EQ
NE} value ["msg"]
{IN
NIN} { value[,value]
lowvalue:highvalue[,lowvalue:highvalue]...
value[,lowvalue:highvalue]... } ["msg"]

MATCH pattern ["msg"] CDIGIT {10
11} ["msg"]

Formatting Statements

  STRIP  { TRAILING 
LEADING
ALL } "character" JUSTIFY { LEFT
RIGHT
CENTER}
FILL {LEADING
TRAILING } "character" UPSHIFT

SET Statements

  SET { TO     { 
value 
index OF value[,value]...}
{fiel d
save field} [TO { value
index OF value[,value]... } ] }

CHANGE Statements

  CHANGE {CFORM TO {NOREPEAT 
REPEAT
REPEAT APPEND}
NFORM TO {[CLEAR
APPEND
FREEZE APPEND] [ "formname"
fieldname
index OF value[,value]...
$RETURN
$HEAD
$END
$REFRESH]}}

Conditional Statement

  IF [ value] editstatement THEN [statement]...
[ statement]...

[ELSE [statement]...
[ statement]...

Control Statement


FAIL ["msg"] STOP

Operands

Whenever value is specified as an operand in a field processing statement, a field name, constant, expression, or a save field name can be used. If the operand is numeric, any of these can be combined into an arithmetic expression whose result is used as the operand.

Another operand, index, is used to retrieve items from a list by an index value. It must be enclosed within parentheses in edit statements; in SET and CHANGE statements, it can be specified without the enclosing parentheses.

Field

The name of any existing field within the same form can be specified as a value operand. When a field name is specified, the value in that field at run-time is used to check the current field.

A field name in an editing statement must describe a field of the same data type (character, numeric, or date) as the current field.

Constant

Constants are divided into categories corresponding to the three main data types: character, numeric and date. In addition, there are four system defined constants:

$EMPTY

equivalent to all blanks; in comparison, $EMPTY is less than any other value (any data type).

$LENGTH

equivalent to the length of the field the last time the form was compiled (numeric data types).

$STATE

equivalent to a table of constants each of which is a two-character upper or lowercase United States state or territory code; refer to Appendix F for the codes (character type; used only in table checks).

$TODAY

equivalent to today's date in the form dd/dd/dd where the order of month day year is determined by the field type (date type only).

Character

Character constants are strings of any character enclosed in single or double quotes.

For example:

    "This is a constant."
'and this is, too!'
$EMPTY
$STATE
Numeric

Numeric constants are digit strings with an optional leading sign and optional decimal point. Commas are not allowed in numeric constants. If the constant has no decimal point, a decimal is assumed at the right of the rightmost (least significant) digit. $EMPTY (all blanks) can be used to indicate a numeric constant less than any non-$EMPTY value, $LENGTH can be used to indicate the length of the current field. The following examples Illustrate numeric constants:

    .23
-123
5000
-3729
$EMPTY
$LENGTH
Date.

A date constant can be any legal date format, but it must be in the order MDY. With Native Language Support, the date constant order (e.g., mmddyy) will not be language dependent. For more information on Native Language Support, see Section 8. To distinguish it from other constants, a date constant must be delimited by exclamation points (!). Note that the date constant in the order MDY is used to check date values in any of the three legal orders: MDY, DMY, or YMD. A special date constant $TODAY is equivalent to the date at execution time. Examples of date constants are:

!MAY 30, 1986!
!12/24/86!
!NOVEMBER 7, 86!
$TODAY
$EMPTY

Arithmetic Expression

Any numeric constant, field, or save field can be combined into an arithmetic expression. The expression is evaluated to generate a constant that can be used to check a field or replace the value of a field. The operators used to form an arithmetic expression are:

+

(add)

-

(subtract)

*

(multiply)

/

(divide)

%

(percent of)

The operators determine the order of evaluation in the standard operator hierarchy where + and - are evaluated after *, /, and %. Operators at the same level are evaluated from left to right. Parentheses may be used to further define the hierarchy. Expressions within parentheses are evaluated first and, if parentheses are nested, the innermost are evaluated first. The % in the expression a%b is equivalent to (a*.01)*b. When $EMPTY is used in an arithmetic expression, the result is always $EMPTY. Thus, $EMPTY with any operator and operand = $EMPTY. The following examples illustrate arithmetic expressions:

F2 + 1

Add 1 to the value in field F2.

QUANTITY * UNITPRICE

Multiply value in QUANTITY by value in UNITPRICE.

TOTALCENTS/ 1000

Divide value in TOTALCENTS by 1,000.

20% (TOTALPRICE - TAX)

Find 20 percent of the value resulting from subtracting TAX from TOTALPRICE.

$EMPTY + 20

The result is always $EMPTY, regardless of the operator or other operand.

NOTE: When the VPLUS intrinsics execute an arithmetic expression, they expect each operand in the expression to have a value; if any operand does not have a value, the result is null. It appears to the user as if the expression had not been executed and no message is issued.

Index Retrieve Operand

An index retrieve operand (enclosed within parentheses) can be used in any edit statement where a constant, field, or expression is legal. An index retrieve operand without enclosing parentheses can be used in SET and CHANGE statements.

An index retrieve operand is specified in the format:

index OF element [,element]...
index

is a numeric type field or save field, or a numeric expression whose value is a positive integer. The index value indicates which element is selected.

element

is a constant, field, save field, or expression. Each element in the list of elements separated by commas must be the same type (character, numeric, or date).

When an operand of this type is specified, its effective value is selected from a list of values according to its position in the list, where the first element of the list is 1. First, the index expression is evaluated, then this value is used to select a final value from the list.

For example:

EQ (N OF "ABC","DEF", "GHI", FIELDX)

If the value of N is 1, the character string "ABC" is the selected operand: if the value of N is 4, the value of FIELDX is selected. If the value of N is negative, zero, or greater than the number of elements, an error message is returned. Note that the operand is enclosed in parentheses because EQ is an edit statement.

SET TO F3 OF F1,15,20, 25,35,40

If the value of F3 is 1, the selected operand is the value of field F1; if F3 is 4, the selected operand is 25. Parentheses are not required in a SET statement.

CHANGE NFORM TO X OF
"FORMA", "FORMB", "FORMC",
OPSELECT

X may be a value between 1 and 4. If its value is 4, the field name OPSELECT is chosen. The value of OPSELECT must be type character to conform to the other elements in the list, and to make sense it should contain a form name. No parentheses are needed in a CHANGE statement.

If an index has a value beyond the number of elements in the list or is $EMPTY, an error is returned.

Feedback to webmaster