Tuto WINDEV Mobile 25
88 Part 4: Programming concepts The loops The loop statements are used to run a process in a recurring way. A specific loop statement is used according to the number of occurrences. Several statements can be used to perform loops: • FOR... • LOOP... • WHILE... The FOR statement The FOR statement is used when the number of occurrences to process is known. This statement is used to manage the number of occurrences via a variable in which the passages performed in the loop will be counted. The syntax of FOR statement is as follows: FOR Subscript = Start Value TO End Value Process to run END For example, the following code runs the process 2000 times: FOR Cnt = 1 TO 2000 // Process to run END Remark: An increment step of subscript can be defined via the STEP keyword. For example, the following code runs the process 2000 times and the Cnt variable decreases by 10: FOR Cnt = 2000 TO 1 STEP -10 // Process to run END The LOOP statement The LOOP statement is used to perform loops when the number of occurrences to process is unknown. In this case, a test must be used to exit from the loop. The syntax of LOOP statement is as follows: LOOP Process to run IF <Expression> THEN BREAK END
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==