PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Statements that can return a value
  • Other statements used to exit from a loop or from a procedure
  • Types returned
  • Multiple return values
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
RESULT is used to exit from the current process (or procedure) and to return a status report.
This status report can correspond to:
The RESULT statement can be used in:
  • The closing code of project,
  • The closing code of window or page,
  • Versions 19 and later
    The closing code of report,
    New in version 19
    The closing code of report,
    The closing code of report,
  • A procedure (conditional test, FOR, FOR EACH, LOOP or WHILE loop, ...).
Versions 16 and later
Universal Windows 10 App This feature is available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This feature is available for the Windows Phone applications.
Universal Windows 10 App This feature is available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This feature is available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This feature is available for the iPhone/iPad applications.
iPhone/iPad This feature is available for the iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
New in version 18
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Example
// 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("Value of control: " + Control_Value)
END
// -- MyProcess procedure
PROCEDURE MyProcess(Control)
IF Control..Type = typInputText THEN
RESULT Control..Value
ELSE
RESULT "Nothing"
END
Syntax

Procedure Hide the details

PROCEDURE <Procedure Name> ([<Parameter>])
IF <Condition> THEN
    RESULT <Value(s) to Return>
ELSE
    RESULT <Value(s) to Return>
END
Notes:
  • 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 from the statement block.
    • Exit from the current process (or procedure).
  • Versions 19 and later
    You have the ability to return several values. See Multiple return values for more details.
    New in version 19
    You have the ability to return several values. See Multiple return values for more details.
    You have the ability to return several values. See Multiple return values for more details.

Closing code of window or page Hide the details

RESULT <Value to Return>
Notes:
  • In this case, <Value to Return> must correspond to the expected value during the call to the window or to the page.
  • Versions 19 and later
    You have the ability to return several values. See Multiple return values for more details.
    New in version 19
    You have the ability to return several values. See Multiple return values for more details.
    You have the ability to return several values. See Multiple return values for more details.

Code for closing the window, the page or the report Hide the details

RESULT <Value to Return>
Notes:
  • In this case, <Value to Return> must correspond to the expected value during the call to the window, page or report.
  • Versions 19 and later
    You have the ability to return several values. See Multiple return values for more details.
    New in version 19
    You have the ability to return several values. See Multiple return values for more details.
    You have the ability to return several values. See Multiple return values for more details.

Closing code of project Hide the details

RESULT <Value to Return>
Note: In this case, <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.
Remarks

Statements that can return a value

Several statements can return a value in a procedure:
  • IF statement
    PROCEDURE <Procedure Name> ([<Parameter>])
    IF <Condition> THEN
    RESULT <Value to Return>
    ELSE
    RESULT <Value to Return>
    END
  • FOR statement
    PROCEDURE <Procedure Name> ([<Parameter>])
    FOR <Control variable> = <Initial value> TO <Final value> [STEP <x>]
    IF <Condition> THEN RESULT <Value to Return>
    END
  • FOR EACH statement
    PROCEDURE <Procedure Name> ([<Parameter>])
    FOR EACH <File> ON <Key item>
    ...
    IF <Condition> THEN RESULT <Value to Return>
    END
  • LOOP statement
    PROCEDURE <Procedure Name> ([<Parameter>])
    LOOP
    ...
    IF <Condition> THEN RESULT <Value to Return>
    ...
    END
  • WHILE statement
    PROCEDURE <Procedure Name> ([<Parameter>])
    WHILE <Condition 1>
    ...
    IF <Condition> THEN RESULT <Value to Return>
    ...
    END
Versions 19 and later
Note: These statements can also return several values. See Multiple return values for more details.
New in version 19
Note: These statements can also return several values. See Multiple return values for more details.
Note: These statements can also return several values. See Multiple return values for more details.

Other statements used to exit from a loop or from a procedure

Several statements are available:
  • RETURN: Exit from the loop and exit from the current process (or procedure).
  • BREAK: Exit from the loop and run the rest of the current process (or procedure).
Close is used to exit from the loop (or procedure) and to close the current window.
Caution: RETURN and RESULT cannot be used in the same process.

Types returned

Versions 15 and later
From version 15, the following types can be used:
  • structure
  • dynamic structure
  • class
  • advanced type
  • array
  • associative array
  • queue
  • stack
  • list
New in version 15
From version 15, the following types can be used:
  • structure
  • dynamic structure
  • class
  • advanced type
  • array
  • associative array
  • queue
  • stack
  • list
From version 15, the following types can be used:
  • structure
  • dynamic structure
  • class
  • advanced type
  • array
  • associative array
  • queue
  • stack
  • list
Versions 19 and later
AndroidAndroid Widget iPhone/iPadApple WatchWindows Mobile

Multiple return values

A procedure, a function, a class method, or a window can return several values.
The following syntax must be used:
RESULT [<Value 1>, <Value 2>, ... <Value N>]
or
RETURN = [<Value 1>, <Value 2>, ... <Value N>]
Example:
// Code of the procedure
PROCEDURE MyProc()

// Process
RESULT(1, 2, 3)


// Code for calling the procedure
( x, y, z ) = MyProc()
// x is set to 1, y to 2 and z to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Note:
  • For a window, Close can also be used to return several values.
  • In a procedure, all the RESULT or RETURN found in this procedure must return the same number of values.
  • The 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:
        Versions 20 and later
        x = MyProc()
        New in version 20
        x = MyProc()
        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 ProcedureName(): ([<Type value 1>, [<Type value 2>, ... , [<Type Value N>]]])
Note: There is no need to specify the type for all return values. You have the ability to assign a type to the return values from version 190040.
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.
Example:
PROCEDURE f()
RESULT(1, 2)

PROCEDURE g(x, y)
RESULT x+y

z is int
z = g(f())
// z is set to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
New in version 19
AndroidAndroid Widget iPhone/iPadApple WatchWindows Mobile

Multiple return values

A procedure, a function, a class method, or a window can return several values.
The following syntax must be used:
RESULT [<Value 1>, <Value 2>, ... <Value N>]
or
RETURN = [<Value 1>, <Value 2>, ... <Value N>]
Example:
// Code of the procedure
PROCEDURE MyProc()

// Process
RESULT(1, 2, 3)


// Code for calling the procedure
( x, y, z ) = MyProc()
// x is set to 1, y to 2 and z to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Note:
  • For a window, Close can also be used to return several values.
  • In a procedure, all the RESULT or RETURN found in this procedure must return the same number of values.
  • The 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:
        Versions 20 and later
        x = MyProc()
        New in version 20
        x = MyProc()
        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 ProcedureName(): ([<Type value 1>, [<Type value 2>, ... , [<Type Value N>]]])
Note: There is no need to specify the type for all return values. You have the ability to assign a type to the return values from version 190040.
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.
Example:
PROCEDURE f()
RESULT(1, 2)

PROCEDURE g(x, y)
RESULT x+y

z is int
z = g(f())
// z is set to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget iPhone/iPadApple WatchWindows Mobile

Multiple return values

A procedure, a function, a class method, or a window can return several values.
The following syntax must be used:
RESULT [<Value 1>, <Value 2>, ... <Value N>]
or
RETURN = [<Value 1>, <Value 2>, ... <Value N>]
Example:
// Code of the procedure
PROCEDURE MyProc()

// Process
RESULT(1, 2, 3)


// Code for calling the procedure
( x, y, z ) = MyProc()
// x is set to 1, y to 2 and z to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Note:
  • For a window, Close can also be used to return several values.
  • In a procedure, all the RESULT or RETURN found in this procedure must return the same number of values.
  • The 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:
        Versions 20 and later
        x = MyProc()
        New in version 20
        x = MyProc()
        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 ProcedureName(): ([<Type value 1>, [<Type value 2>, ... , [<Type Value N>]]])
Note: There is no need to specify the type for all return values. You have the ability to assign a type to the return values from version 190040.
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.
Example:
PROCEDURE f()
RESULT(1, 2)

PROCEDURE g(x, y)
RESULT x+y

z is int
z = g(f())
// z is set to 3
AndroidAndroid Widget The multiple return values are available from version 23.
Versions 23 and later
AndroidAndroid Widget The multiple return values are now available.
New in version 23
AndroidAndroid Widget The multiple return values are now available.
AndroidAndroid Widget The multiple return values are now available.
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo Result
//Pegar Retorno
( SAI_Texto1 , SAI_Texto2 ) = retorna_valores()
//---------------------------------
PROCEDURE retorna_valores()
_a is int=1
_b is int=2
RESULT(_a, _b)
//------------------
//Blog com Video e Exemplos
http://windevdesenvolvimento.blogspot.com.br/2016/01/windev21-curso-229-result-pegar-mais-de.html
De matos AMARILDO
20 Jan. 2016
Result
Remember: If you do a RESULT = "" (Equal sign) by a mistake it will not return from your function, but continue.
TOR-BJARNE HENRIKSE
28 Feb. 2014