PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Code to run
  • Exiting from a loop
  • Running the next iteration
  • Loop without end
  • External variable in a loop
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
The statement block is repeated endlessly. The number of iterations in the statement block is not checked, there is no expression to evaluate.
Versions 16 and later
Universal Windows 10 App This feature is available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This feature is available for the Windows Phone applications.
Universal Windows 10 App This feature is available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This feature is available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This feature is available for the iPhone/iPad applications.
iPhone/iPad This feature is available for the iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
New in version 18
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Versions 21 and later
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
New in version 21
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Example
// Exit according to an IF condition
LOOP
        // Read a line in the text file
        ALine = fReadLine(FileNum)
        IF ALine = EOT THEN BREAK
        ProcessLine(ALine)
END
// Exit according to a WHILE condition
LOOP
        // Read a line in the text file
        ALine = fReadLine(FileNum)
        ProcessLine(ALine)
DO WHILE ALine <> EOT
// Exit according to an iteration
LOOP (10)
        // Read a line in the text file
        ALine = fReadLine(FileNum)
        ProcessLine(ALine)
END
Syntax

Loop with exit according to an "IF" condition Hide the details

LOOP
   ...
   IF <Condition> THEN BREAK
   ...
END
<LOOP>:
Marks the beginning of statement block.
<BREAK>:
Used to exit from the statement block.
<END>:
Marks the end of statement block.

Loop with exit according to a "WHILE" condition Hide the details

LOOP
...
DO WHILE <Condition>
<LOOP>:
Marks the beginning of statement block.
<DO WHILE>:
Marks the end of statement block. Used to exit from the statement block. The lines of the loop found before this statement are run.

Loop with exit according to the number of iterations Hide the details

LOOP (<Number of Iterations>)
...
END
<LOOP>:
Marks the beginning of statement block.
<Number of Iterations>:
Number of iterations to perform. The program will exit the loop when the number of iterations is reached.
<END>:
Marks the end of statement block.
Remarks

Code to run

The code to run is found between the LOOP and END statements.

Exiting from a loop

Several statements are available:
  • RETURN: Exit from the loop and exit from the current process (or procedure).
  • RESULT: Return a status report to the calling process. Exit from the loop and exit from the current process (or procedure).
  • BREAK: Exit from the loop and run the rest of the current process.
Close is used to exit from the loop and to close the current window.
Caution: RETURN and RESULT cannot be used in the same process.

Running the next iteration

To directly run the next iteration without ending the code of the current iteration, use the CONTINUE statement:
LOOP
...
IF <Condition> THEN  CONTINUE // Go back to the LOOP keyword
...
END

Loop without end

During the compilation of the project, an endless loop (no BREAK, RETURN or RESULT) is signaled by a warning.

External variable in a loop

A variable declared by EXTERN cannot be used in a loop.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment