PreviousNextIndex

REPEAT statement

Begins a block of statements that are processed repeatedly until the block ends in one of several ways. Use an END statement to end a REPEAT block.

Block properties

Iteration, record scoping, frame scoping, transactions by default.

Syntax

[ label : ]  
REPEAT 
  [ FOR record [ , record ] ... ] 
  [ preselect-phrase ] 
  [ query-tuning-phrase ] 
  [ variable = expression1 TO expression2 [ BY k ] ] 
  [ WHILE expression ] 
  [ TRANSACTION ]  
  [ STOP-AFTER expression ] 
  [ on-endkey-phrase ] 
  [ on-error-phrase ] 
  [ on-quit-phrase ] 
  [ on-stop-phrase ] 
  [ frame-phrase ] 
  [ catch-block [ catch-block ... ] ] 
  [ finally-block ] : 
  repeat-body 

FOR record [ , record ] . . .
preselect-phrase
query-tuning-phrase
variable = expression1 TO expression2 [ BY k ]
WHILE expression
TRANSACTION
STOP-AFTER expression
on-endkey-phrase
on-error-phrase
on-quit-phrase
on-stop-phrase
frame-phrase
repeat-body
repeat-logic
catch-block
finally-block
END
Example

In this menu procedure, if you press END-ERROR or ENDKEY when the procedure prompts you for your menu selection, any data you have entered as a selection is undone and the procedure continues to prompt you for a menu selection:

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 */ 

Notes
See also

CATCH statement, DO statement, END statement, FINALLY statement, Frame phrase, ON ENDKEY phrase, ON ERROR phrase, ON QUIT phrase, ON STOP phrase


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex