ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / Structured statements
  • Other statements used to exit a loop or a procedure
  • Using the RETURN keyword to return a value
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
The RETURN statement is used to exit a statement block and the current process (or procedure).
The RETURN statement can be used in:
In a procedure, you also have the ability to assign a value to the RETURN keyword. This value can be re-read at any time. This value will be automatically returned when exiting the procedure (standard exit from the procedure or exit from the procedure via the RETURN keyword).
Syntax

Procedure

PROCEDURE <Procedure name> ([<Parameter>])
  IF <Condition> THEN RETURN
  ...
  END

FOR statement

FOR <Control variable> = <Initial value> TO <Final value> [STEP <x>]
  IF <Condition> THEN RETURN
END

FOR EACH statement

FOR EACH <File> ON <Key item>
  IF <Condition> THEN RETURN
END

LOOP statement

LOOP
  ...
  IF <Condition> THEN RETURN
  ...
END

WHILE statement

WHILE <Condition 1>
  ...
  IF <Condition> THEN RETURN
  ...
END
The following operations are performed if <Condition> is True:
  • Exit the statement block.
  • Exit the current process (or procedure).
Remarks

Other statements used to exit a loop or a procedure

The BREAK statement exits the loop and executes the rest of the current process (or procedure).
Close is used to exit the loop (or procedure) and close the current window.

Using the RETURN keyword to return a value

In a procedure, you also have the ability to assign the return value before the actual exit from the procedure. For example:
...
RETURN = fReadLine(nFile)
fClose(nFile)
You also have the ability to re-read the value assigned by RETURN so that there is no need to declare a local variable to contain the result. For example:
IF RETURN = 1 THEN...
The value assigned to RETURN will be returned to the calling process:
  • at the end of procedure
  • when using the RETURN keyword to exit the process (equivalent to the RETURN statement).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help