Begins a block of statements that are processed repeatedly until the block ends. An END statement is used to terminate a REPEAT block.
This is the syntax for the REPEAT block:
[ label : ] REPEAT [ FOR record[ , record ]...] [ preselect-phrase ] [ query-tuning-phrase ] [ variable = expression1 TO expression2 [ BY k ]] [ WHILE expression ] [ TRANSACTION ] [ stop-after-phrase ] [ on-endkey-phrase ] [ on-error-phrase ] [ on-quit-phrase ] [ on-stop-phrase ] [ frame-phrase ] : <block of statements> END. |
Names a record buffer and scopes the buffer to the block. The scope of a record determines when the buffer is cleared and the record written back to the database. See ABL Essentials for more information on record scoping and blocks.
To access a record in a table defined for multiple databases, you must qualify the record's table name with the database name. See Record phrase for more information.
Goes through a table to select the records that meet the criteria you specify in a record-phrase. PRESELECT creates a temporary index that contains pointers to each of the preselected records in the database table. You can then use other statements, such as FIND NEXT, to process those records. This is the syntax for the preselect-phrase:
PRESELECT [ EACH | FIRST | LAST ]record-phrase [ , { EACH | FIRST | LAST }record-phrase]... [[ BREAK ]{ BY expression[ DESCENDING ]}...] |
For more information, see PRESELECT phrase.
Allows programmatic control over the execution of a DataServer query. This is the syntax for the query-tuning-phrase:
QUERY-TUNING ( [ BIND-WHERE | NO-BIND-WHERE ] [ CACHE-SIZE integer] [ DEBUG { SQL | EXTENDED }| NO-DEBUG ] [ INDEX-HINT | NO-INDEX-HINT ] [ JOIN-BY-SQLDB | NO-JOIN-BY-SQLDB ] [ LOOKAHEAD | NO-LOOKAHEAD ] [ SEPARATE-CONNECTION | NO-SEPARATE-CONNECTION ] ) |
For more information see the OpenEdge DataServer Guides (Use the Microsoft SQL Data Server and Use the Microsoft SQL Data Server).
Indicates the name of a field or variable whose value you are incrementing in a loop. expression1 is the starting value for variable on the first iteration of the loop. k is the amount to add to variable after each iteration and must be a constant. When variable exceeds expression2 (or is less than expression2 if k is negative), the loop ends. Because expression1 is compared to expression2 at the start of the first iteration of the block, the block can be executed zero times. expression2 is reevaluated with each iteration of the block.
The REPEAT block iterates as long as the condition specified by expression is TRUE. expression is any combination of constants, field names, and variable names that yield a logical value.
Identifies the REPEAT block as a system transaction block. The AVM starts a system transaction for each iteration of a transaction block if there is no active system transaction. See ABL Essentials for more information on transactions.
Specifies a time-out value (in seconds) for the block. This is the syntax for the STOP-AFTER phrase:
For more information see STOP-AFTER phrase.
Describes the processing that takes place when the ENDKEY condition occurs during a block. This is the syntax for the ON ENDKEY phrase:
ON ENDKEY UNDO [label1] [ , LEAVE [label2] | , NEXT [label2] | , RETRY [label1] | , RETURN [return-value| ERROR [return-value|error-object-expression]| NO-APPLY ] |
For more information see the ON ENDKEY phrase.
Describes the processing that takes place when there is an error during a block. This is the syntax for the ON ERROR phrase:
ON ERROR UNDO [label1] [ , LEAVE [label2] | , NEXT [label2] | , RETRY [label1] | , RETURN [return-value| ERROR [return-value|error-object-expression]| NO-APPLY ] | , THROW ] |
For more information see the ON ERROR phrase.
Describes the processing that takes place when a QUIT statement is executed during a block. This is the syntax for the ON QUIT phrase:
ON QUIT [ UNDO [label1]] [ , LEAVE [label2] | , NEXT [label2] | , RETRY [label1] | , RETURN [return-value| ERROR [return-value|error-object-expression]| NO-APPLY ] ] |
For more information see the ON QUIT phrase.
Describes the processing that takes place when the STOP conditions occurs during a block. This is the syntax for the ON STOP phrase:
ON STOP UNDO [label1] [ , LEAVE [label2] | , NEXT [label2] | , RETRY [label1] | , RETURN [return-value| ERROR [return-value|error-object-expression]| NO-APPLY ] ] |
For more information see the ON STOP phrase.
Specifies the overall layout and processing properties of a frame. This is the syntax for the frame phrase:
WITH [ ACCUM [ max-length ]] [ at-phrase ][ ATTR-SPACE | NO-ATTR-SPACE ] [ CANCEL-BUTTON button-name][ CENTERED ] [ color-specification] [ COLUMN expression][n COLUMNS ] [ CONTEXT-HELP ][ CONTEXT-HELP-FILE help-file-name] [ DEFAULT-BUTTON button-name] [ DROP-TARGET ] [[expression] DOWN ][ EXPORT ] [ WIDGET-ID id-number][ FONT expression] [ FRAME frame] [ INHERIT-BGCOLOR | NO-INHERIT-BGCOLOR ] [ INHERIT-FGCOLOR | NO-INHERIT-FGCOLOR ] [ KEEP-TAB-ORDER ][ NO-BOX ] [ NO-HIDE ][ NO-LABELS ][ USE-DICT-EXPS ] [ NO-VALIDATE ][ NO-AUTO-VALIDATE ] [ NO-HELP ][ NO-UNDERLINE ] [ OVERLAY ][ PAGE-BOTTOM | PAGE-TOP ][ RETAIN n] [ ROW expression][ SCREEN-IO | STREAM-IO ] [ SCROLL n][ SCROLLABLE ][ SIDE-LABELS ] [ size-phrase][ STREAM stream| STREAM-HANDLE handle][ THREE-D ] [ title-phrase][ TOP-ONLY ][ USE-TEXT ] [ V6FRAME [ USE-REVVIDEO | USE-UNDERLINE ]] [ VIEW-AS DIALOG-BOX ][ WIDTH n][ IN WINDOW window] |
For more information, see the Frame phrase.
In this menu procedure, if you press END-ERROR or ENDKEY when prompted for your menu selection, any selection data you have entered is undone and the procedure continues to prompt you:
r-rpt.p
DEFINE VARIABLE Selection AS INTEGER NO-UNDO FORMAT "9". FORM SKIP(3) "0 - Exit" at 32 "1 - Edit Customer File" at 32 "2 - List Customer File" at 32 "3 - Edit Item File" at 32 "4 - List Item File" at 32 "Enter Choice" TO 30 Selection AUTO-RETURN HEADER "Application Name" "Master Menu" AT 34 "Company" TO 79 WITH NO-BOX NO-LABELS CENTERED FRAME menu. /* Create the procedures that are called from the following block. */ REPEAT ON ENDKEY UNDO, RETRY: UPDATE Selection WITH FRAME menu. HIDE FRAME menu. CASE(Selection): WHEN 0 THEN LEAVE. WHEN 1 THEN RUN custedit.p. WHEN 2 THEN RUN custrpt.p. WHEN 3 THEN RUN itemedit.p. WHEN 4 THEN RUN itemrpt.p. OTHERWISE DO: BELL. MESSAGE "Not a valid choice. Try again.". END. END CASE. END. /* REPEAT */ |
In this example, if you change Customer 1 to Customer 300, you see that Customer record again at the end of the procedure.
When you use the PRESELECT option, the AVM builds a special index table that is not updated when index values change:
In this example, if you change Customer 2 to Customer 200, you do not see that Customer record until you look it up with a new procedure.