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 - do while pre-conditional iterative execution start http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 do while            Pre-conditional iterative execution start
------------------------------------------------------------------------------
 Syntax
   do while <condition>
      [ <code> ]
      [ loop ]
      [ exit ]
   enddo

 Arguments
   <condition> is an expression that evaluates to a logical value.
   <code> is a block of executable code.

 Description
   The do while provides basic iterative conditional control. Any
   commands within the do while block are executed as long as the logical
   expression is true.

   The do while construct evaluates the logical expression on entry into the
   loop, therefore, depending on the result of logical expression, the loop
   might never be executed.

   The do while loops may be nested.

 Example
   #define EXAMPLE_STATEMEN
   #include example.hdr

   proc Test_dowhile
   vardef
      uint    n
      logical lRepeated
   enddef
   n := 1                             // initialize loop control variables
   lRepeated := .f.
   do while n < 10                    // main loop control statement
      ? 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
   enddo
   endproc

   proc main
   Test_dowhile()
   endproc

See Also: enddo exit loop

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