PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • CONTINUE statement: example not to do:
  • Example for using the "CONTINUE:" label
  • "CONTINUE:" statement: Case of nested loops
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
CONTINUE statement/"CONTINUE:" label
In french: Continuer
The CONTINUE keyword can correspond:
  • the CONTINUE statement:
    The CONTINUE statement is used to directly go to the beginning of the next iteration without ending the code of the current iteration.
    The CONTINUE statement can be used in the following types of loops:
  • Versions 19 and later
    the CONTINUE: label:
    The "CONTINUE:" label is used to declare a common code in a loop. This code will be run:
    • for each iteration of the loop.
    • if the "CONTINUE" statement is found in the loop. In this case, the code found between the "CONTINUE" statement and the "CONTINUE:" label will not be run.
    New in version 19
    the CONTINUE: label:
    The "CONTINUE:" label is used to declare a common code in a loop. This code will be run:
    • for each iteration of the loop.
    • if the "CONTINUE" statement is found in the loop. In this case, the code found between the "CONTINUE" statement and the "CONTINUE:" label will not be run.
    the CONTINUE: label:
    The "CONTINUE:" label is used to declare a common code in a loop. This code will be run:
    • for each iteration of the loop.
    • if the "CONTINUE" statement is found in the loop. In this case, the code found between the "CONTINUE" statement and the "CONTINUE:" label will not be run.
Syntax

CONTINUE statement used in a FOR statement Hide the details

FOR <Control variable> = <Initial value> TO <Final value> [STEP <x>]
...    
IF <Condition> THEN CONTINUE
...
END
Remark: If <Condition> is True:
  • The code found after the CONTINUE statement is not run.
  • The loop is run from the beginning of the FOR statement.
  • The <Control variable> is incremented.

CONTINUE statement used in a FOR EACH statement Hide the details

FOR EACH <File> ON <Key item>
   ...
   IF <Condition> THEN CONTINUE
   ...
END
Remark: If <Condition> is True:
  • The code found after the CONTINUE statement is not run.
  • The loop is run from the beginning of the FOR EACH statement.
  • The move to the next record is automatically performed.

CONTINUE statement used in a WHILE statement Hide the details

WHILE <Condition 1>
   ...    
IF <Condition2> THEN CONTINUE
   ...
END
Remark: If <Condition 2> is True:
  • The code found after the CONTINUE statement is not run.
  • The loop is run from the beginning of the WHILE statement.
Remarks

CONTINUE statement: example not to do:

In this code, using the CONTINUE keyword triggers the non-execution of HReadNext:
HReadFirst(Account, NoAccount)
WHILE NOT HOut()
        IF Account.NoAccount = "XXX" THEN CONTINUE
        Trace(Account.NoAccount)
        HReadNext(Account, NoAccount)
END
Versions 19 and later

Example for using the "CONTINUE:" label

In this example, the following elements are added:
  • the amount of each invoice in the TotInv variable.
  • the amount if it is a credit in the TotCredit variable .
TotInv is currency
TotCredit is currency

HReadFirst(Invoice, InvNum)
WHILE NOT HOut()
IF Invoice.Invoice_Type <> "Credit" THEN CONTINUE  
// Goes to the CONTINUE: label directly
// Adds the credits here
TotCredit += Invoice.Amount

CONTINUE:
// Adds all the amounts
TotInv += Invoice.Amount
HReadNext(Invoice, InvNum)
END
New in version 19

Example for using the "CONTINUE:" label

In this example, the following elements are added:
  • the amount of each invoice in the TotInv variable.
  • the amount if it is a credit in the TotCredit variable .
TotInv is currency
TotCredit is currency

HReadFirst(Invoice, InvNum)
WHILE NOT HOut()
IF Invoice.Invoice_Type <> "Credit" THEN CONTINUE  
// Goes to the CONTINUE: label directly
// Adds the credits here
TotCredit += Invoice.Amount

CONTINUE:
// Adds all the amounts
TotInv += Invoice.Amount
HReadNext(Invoice, InvNum)
END

Example for using the "CONTINUE:" label

In this example, the following elements are added:
  • the amount of each invoice in the TotInv variable.
  • the amount if it is a credit in the TotCredit variable .
TotInv is currency
TotCredit is currency

HReadFirst(Invoice, InvNum)
WHILE NOT HOut()
IF Invoice.Invoice_Type <> "Credit" THEN CONTINUE  
// Goes to the CONTINUE: label directly
// Adds the credits here
TotCredit += Invoice.Amount

CONTINUE:
// Adds all the amounts
TotInv += Invoice.Amount
HReadNext(Invoice, InvNum)
END
Versions 19 and later

"CONTINUE:" statement: Case of nested loops

When you have several nested loops, you must sometimes continue on the next iteration of one of the previous level without ending the current loop.
To do so, the CONTINUE statement accepts a parameter specifying the number of levels to move up. The syntax is as follows:
CONTINUE[<Number of levels>]
where <Number of levels> is an integer between 1 and N, N representing the number of nested levels for the loop.
For example:
x, y, z are int

FOR x = 1 TO 15 // Loop 1
FOR y = 1 TO 25 // Loop 2
FOR z = 1 TO 50 // Loop 3
IF <My condition is checked> THEN
CONTINUE(1)  
// Stops the browse of loop 3
// and goes to the following iteration of loop 2
END
END
END
END
New in version 19

"CONTINUE:" statement: Case of nested loops

When you have several nested loops, you must sometimes continue on the next iteration of one of the previous level without ending the current loop.
To do so, the CONTINUE statement accepts a parameter specifying the number of levels to move up. The syntax is as follows:
CONTINUE[<Number of levels>]
where <Number of levels> is an integer between 1 and N, N representing the number of nested levels for the loop.
For example:
x, y, z are int

FOR x = 1 TO 15 // Loop 1
FOR y = 1 TO 25 // Loop 2
FOR z = 1 TO 50 // Loop 3
IF <My condition is checked> THEN
CONTINUE(1)  
// Stops the browse of loop 3
// and goes to the following iteration of loop 2
END
END
END
END

"CONTINUE:" statement: Case of nested loops

When you have several nested loops, you must sometimes continue on the next iteration of one of the previous level without ending the current loop.
To do so, the CONTINUE statement accepts a parameter specifying the number of levels to move up. The syntax is as follows:
CONTINUE[<Number of levels>]
where <Number of levels> is an integer between 1 and N, N representing the number of nested levels for the loop.
For example:
x, y, z are int

FOR x = 1 TO 15 // Loop 1
FOR y = 1 TO 25 // Loop 2
FOR z = 1 TO 50 // Loop 3
IF <My condition is checked> THEN
CONTINUE(1)  
// Stops the browse of loop 3
// and goes to the following iteration of loop 2
END
END
END
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment