COMMANDUnder review
LOOP
LOOP (FOR ... NEXT / WHILE ... ENDDO)Skips the remainder of a FOR or WHILE iteration.
Overview
In FOR the counter advances normally; in WHILE the condition is reevaluated. Placing WHILE progress after LOOP can cause endless repetition. Unlike EXIT, LOOP does not terminate the loop. (Sources: refs. 1–1.)
Syntax
LOOP (FOR ... NEXT / WHILE ... ENDDO)Return value
Flow control; no returned value.
Commented example
#Include "Protheus.ch"
User Function Ed512()
Local nI
For nI := 1 To 5
// Skip only iteration number 3.
If nI == 3
Loop
EndIf
ConOut(cValToChar(nI))
Next
Return NilExpected result
Displays 1, 2, 4 and 5. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Ensure required progress and cleanup occur before skipping an iteration.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.