Wend
Parameters
| None. |
Description
|
Closes a While loop. Reaching Wend sends execution back up to the matching While, where the condition is tested again. If it still holds, the body runs once more; if not, the program carries on below the Wend. Every While needs one, and each Wend pairs with the nearest unfinished While, so nested loops match innermost first. Forget it and the compiler stops with "Expecting 'Wend'", usually pointing at whatever came after your loop rather than at the loop itself - if that error looks nonsensical, count your Wends. To break out early without waiting for the condition, use Exit, which jumps past the Wend. See also: While, Exit, Repeat, Next. |
Example
; Wend Example ; ------------ ; Recharge the shield until it is full shield=25 Print "Shield generator online. Shield at "+shield+"%" While shield<100 shield=shield+15 If shield>100 Then shield=100 Print "Recharging ... shield at "+shield+"%" ; Wend jumps back to the While line, where the condition is tested again Wend Print "Shields fully charged!" Print "" Print "Press any key to close the example" WaitKey End
Index