REPEAT [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation
HP Transact Reference Manual
REPEAT
Repeats execution of a simple or compound statement until a specified
condition is true.
Syntax
REPEAT statement UNTIL condition-clause;
When REPEAT is encountered, the simple or compound statement following
it is executed and then the condition-clause is tested. The
condition-clause includes one or more conditions, each made up of a
test-variable, a relational-operator, and one or more values. Multiple
conditions are joined by AND or OR. Execution of the statement following
REPEAT continues until the test gives a value of true.
Statement Parts
statement A simple or compound Transact statement can follow REPEAT. A
compound statement is bracketed with a DO/DOEND pair.
condition- One or more conditions, connected by AND or OR, where
clause
AND is a logical conjunction. The condition clause
is true if all of the conditions are true; it is
false if one of the conditions is false.
OR is a logical inclusive OR. The condition clause
is true if any of the conditions is true; it is
false if all of the conditions are false.
Each condition contains a test-variable, relational-operator,
and one or more values in the following format:
test-variable relational-operator value[,value]...
test- Can be one or more of the following:
variable
(item-name The value in the data register that corresponds
[(sub- to item-name. The item-name may be subscripted
script)]) if an array item is being referenced. (See
"Array Subscripting" in Chapter 3.)
[arithmetic An arithmetic expression containing item names
expression] and/or constants. The expression is evaluated
before the comparison is made. (See LET verb
for more information.)
_______________________________________________
NOTE An arithmetic-expression must be enclosed
in square brackets ([ ]).
_______________________________________________
EXCLA- Current status of the automatic null response to
MATION a prompt set by a user responding with an
exclamation point (!) to a prompt. (See "Data
Entry Control Characters" in Chapter 5.) If the
null response is set, the EXCLAMATION test
variable is a positive integer; if not set, it
is zero. The default is 0.
FIELD Current status of FIELD command qualifier. If a
user qualifies a command with FIELD, the FIELD
test variable is a positive integer. Otherwise,
it is a negative integer. The default is <0.
INPUT The last value input in response to the INPUT
prompt.
PRINT Current status of PRINT or TPRINT command
qualifier. If the user qualifies a command with
PRINT, the PRINT test variable is an integer
greater than zero and less than 10; if a command
is qualified with TPRINT, PRINT is an integer
greater than 10; if neither qualifier is used,
PRINT is a negative integer. The default is <
0.
REPEAT Current status of REPEAT command qualifier. If
the user qualifies a command with REPEAT, the
REPEAT test variable is a positive integer;
otherwise, REPEAT is a negative integer. The
default is < 0.
SORT Current status of SORT command qualifier. If
the user qualifies a command with SORT, the
value of the SORT test variable is a positive
integer; otherwise SORT is a negative integer.
The default is < 0.
STATUS The value of the 32-bit status register set by
the last data set or file operation, data entry
prompt, or external procedure call.
relational-Specifies the relation between the test-variable and the
value. It can be one of the following:
operator
= equal to
<> not equal to
< less than
<= less than or equal to
> greater than
>= greater than or equal to
value Any of test variable values or the value against which the
test-variable is compared. The value may be an arithmetic
expression, which will be evaluated before the comparison is
made. The allowed value depends on the test variable, as
shown in the comparison below. Alphanumeric strings must be
enclosed in quotation marks.
If the test- The value must be:
variable is:
item-name An alphanumeric string, a numeric value, an
arithmetic expression, a reference to a variable
as in (item-name) or a class condition as
described below.
[arithmetic A numeric value, an arithmetic expression, or an
expression] expression, or a reference to a variable as in
(item-name). (See the LET verb for more
information.)
INPUT An alphanumeric string.
EXCLA- A positive or negative integer, or an
MATION
expression.
FIELD
PRINT
REPEAT
SORT
STATUS A 32-bit integer or an expression.
If more than one value is given, then:
* The relational-operator can be only "=" or "<>".
* When the relational operator is "=", the action is
taken if the test-variable is equal to value1 OR value2
OR...valuen. In other words, a comma in a series of
values is interpreted as an OR.
* When the relational operator is "<>", the action is
taken if the test-variable is not equal to value1 AND
value2 AND... valuen. In other words, a comma in a
series of values is interpreted as an AND when the
operator is "<>".
When the test variable is an item-name, the value can be one
of the following class conditionals, which are used to
determine whether a string is all numeric or alphabetic. The
operator can only be "=" or "<>".
NUMERIC This class condition includes the ASCII
characters 0 through 9 and a single
operational leading sign. Leading and
trailing blanks around both the number and
sign are ignored. Decimal points are not
allowed in NUMERIC data. This class test is
only valid when the item has the type X, U,
9, or Z, or when the item is in the input
register.
ALPHABETIC This class condition includes all ASCII
native language alphabetic characters (upper
and lowercase) and space. This class test is
only valid for item names of type X or U.
ALPHABETIC- This class condition includes all ASCII
LOWER lowercase native language alphabetic
characters and space. This class test is
only valid for type X or U.
ALPHABETIC- This class condition includes all ASCII
UPPER uppercase native language alphabetic
characters and space. This class test is
only valid for item names of type X or U.
Order of Evaluation
When complex conditions are included, the operator precedence is:
* Arithmetic expressions are evaluated.
* Truth values are established for simple relational conditions.
* Truth values are established for simple class conditions.
* Multiple value conditions are evaluated.
* Truth values are established for complex AND conditions.
* Truth values are established for complex OR conditions.
Parentheses can be used to control the order of precedence when
conditional clauses are being evaluated. In multiple value conditions,
evaluation terminates as soon as a truth value is determined.
Examples
The following example performs the compound statement between the
DO/DOEND pair until the value of OFFICE-CODE exceeds 49.
REPEAT
DO
GET(SERIAL) MASTER;
:
PUT SEQFILE;
DOEND
UNTIL (OFFICE-CODE) > 49;
The following are two examples of using the REPEAT verb:
REPEAT
DO
LET (TOTAL-OVERDUE) = (TOTAL-OVERDUE) + (AMT-OVERDUE);
FIND(SERIAL) CUST-INVOICE,STATUS;
DOEND
UNTIL (TOTAL-OVERDUE) > 999999.99 OR
(TOTAL-OVERDUE) > (MIN-OVERDUE) AND
(CUST-CODE) = "NEW";
REPEAT
FIND(SERIAL) STK-ON-HAND,STATUS
UNTIL ((WEIGHT) > [(KILO-PER-METER) * (METERS)] AND
(METERS) > (MIN-LENGTH) OR
(PRICE) > [(UNIT-PRICE) * (KILO-PER-METER) * (METERS)]);
MPE/iX 5.0 Documentation