AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Sintaxis WLanguage / Instrucciones estructuradas
  • Statements that can return a value
  • Other statements used to exit a loop or a procedure
  • Types returned
  • Multiple return values
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
The RETURN statement is used to exit the current event, process or procedure and return a result.
This status report can correspond to:
The RETURN statement can be used in:
  • The project closing code,
  • The closing code of window or page,
  • The closing code of report,
  • A procedure (conditional test, FOR, FOR EACH, LOOP or WHILE loop, ...).
Ejemplo
// Call to a procedure that returns NOTHING if a problem occurs
// Different process according to the return value
Control_Value is string
Control_Value = MyProcess(Control_Name)
IF Control_Value = "Nothing" THEN 
	Info("No value was calculated")
ELSE
	Info("Field value: " + Field_Value)
END
// -- MyProcess procedure
PROCEDURE MyProcess(Control)
IF Control..Type = typInputText THEN
RETURN Control..Value
ELSE
RETURN "Nothing"
END
Sintaxis

Procedure Ocultar los detalles

PROCEDURE <Procedure name> ([<Parameter>])
IF <Condition> THEN
    RETURN <Value(s) to return>
ELSE
    RETURN <Value(s) to return>
END
Remarks:
  • The following operations are performed if <Condition> is fulfilled:
    • Return a status report to the calling process. The type and value of <Value to return> depend on the value expected by the process calling the procedure.
    • Exit the statement block.
    • Exit the current process (or procedure).
  • You have the ability to return several values. For more details, see Multiple return values.

Code for closing the window, the page or the report Ocultar los detalles

RETURN <Value to return>
Remarks:
  • In this case, <Value to return> must correspond to the expected value during the call to the window, page or report.
  • You have the ability to return several values. For more details, see Multiple return values.

Project closing code Ocultar los detalles

RETURN <Value to return>
Note: In this case, the <Value to return> must be an integer. This value can be retrieved by any application. For a WINDEV application, the value returned by another application can be retrieved by ExeRun.
Observaciones

Statements that can return a value

Several statements can return a value in a procedure:
  • IF statement
    PROCEDURE <Procedure name> ([<Parameter>])
    IF <Condition> THEN
    RETURN <Value to return>
    ELSE
    RETURN <Value to return>
    END
  • FOR statement
    PROCEDURE <Procedure name> ([<Parameter>])
    FOR <Control variable> = <Initial value> TO <Final value> [STEP <x>]
    IF <Condition> THEN RETURN <Value to return>
    END
  • FOR EACH statement
    PROCEDURE <Procedure name> ([<Parameter>])
    FOR EACH <File> ON <Key item>
    ...
    IF <Condition> THEN RETURN <Value to return>
    END
  • LOOP statement
    PROCEDURE <Procedure name> ([<Parameter>])
    LOOP
    ...
    IF <Condition> THEN RETURN <Value to return>
    ...
    END
  • WHILE statement
    PROCEDURE <Procedure name> ([<Parameter>])
    WHILE <Condition 1>
    ...
    IF <Condition> THEN RETURN <Value to return>
    ...
    END
Note: These instructions can also return several values. For more details, see Multiple return values.

Other statements used to exit a loop or a procedure

Close is used to exit the loop (or procedure) and close the current window.

Types returned

The following types can be returned:
  • structure
  • dynamic structure
  • class
  • advanced type
  • array
  • associative array
  • queue
  • stack
  • list
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsLinuxAndroidWidget Android iPhone/iPadApple WatchJavaCódigo de Usuario (UMC)

Multiple return values

A procedure, a function, a class method, or a window can return several values.
The following syntax must be used:
RETURN (<Valeur 1>, <Valeur 2>, ... <Valeur N>)
or
RETURN = (<Valeur 1>, <Valeur 2>, ... <Valeur N>)
Example:
// Code of the procedure
PROCEDURE MyProc()
 
// Process
RETURN (1, 2, 3)
 
 
// Code for calling the procedure
( x, y, z ) = MyProc()
// x is set to 1, y to 2 and z to 3
Note:
  • For a window, Close can also be used to return multiple values.
  • In a procedure, all the RETURN keywords must return the same number of values.
  • Multiple returns are not allowed in a stored procedure.
  • The properties cannot use multiple values.
  • For a procedure, the returned values can correspond to simple types (integer, boolean, ...) or to complex types (structures, ...).
  • For a window or for a report, the returned values can correspond to simple types (integer, boolean, ...).
  • If the procedure, window or report returns several values, it is not required to retrieve all the values. You have the ability to read a single one. For example:
    • Reading all the values:
      ( x, y, z ) = MyProc()
    • Reading a single value:
      • Reading the first value:
        (x) = MyProc()
        or:
        x = MyProc()
      • Reading the second value:
        (,y) = MyProc()
Types of return values
You have the ability to assign a type to the return values. The syntax is as follows:
PROCEDURE NameProcedure(): ([<Value type 1>, [<Value type 2>, ... , [<Value type N>]]])
Note: It is not mandatory to type all return values..
Multiple return value used as parameter
A multiple return value can be passed as parameter to a WLanguage procedure or function.
Example:
PROCEDURE f()
RETURN (1, 2)
 
PROCEDURE g(x, y)
RETURN x+y
 
z is int
z = g(f())
// z is set to 3
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 04/10/2024

Señalar un error o enviar una sugerencia | Ayuda local