Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - repeat post-conditional iterative execution start http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 repeat              Post-conditional iterative execution start
------------------------------------------------------------------------------
 Syntax
   repeat
      [ <code> ]
      [ loop ]
      [ exit ]
   until <condition>

 Arguments
   None.

 Description
   The repeat statement starts a loop construct that can be used
   as an alternative to the do while structure.

   The repeat/until construct evaluates the logical expression after
   the command block has been executed. This means that the command
   block will always execute at least once. Note that, unlike do while,
   repeat/until terminates when the logical expression becomes true,
   not false. Like do while, the repeat/until construct may be nested.

 Example
   #define EXAMPLE_STATEMEN
   #include example.hdr

   proc Test_repeat
   vardef
      uint n
      logical lRepeated
   enddef
   n := 1                             // initialize loop control variables
   lRepeated := .f.
   repeat                             // start of loop
      ? n                             // initial processing
      if n == 5 .and. .not. lRepeated // intermediate condition 1
         ? "Repeat"
         lRepeated := .t.             // set a loop control variable
         loop                         // restart cycle
      endif
      if lRepeated                    // intermediate condition 2
         ? "Finish"
         exit                         // leave cycle
      endif
      n++                             // continued processing
   until n >= 9                       // main loop control statement
   endproc

   proc main
   Test_repeat()
   endproc

See Also: do while exit loop until

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson