PC SOFT

WINDEV的在线文档

  • Statements that can return a value
  • Other statements used to exit from a loop or from a procedure
  • Types returned
  • Multiple return values
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

返回 is used to exit from the current process (or procedure) and to return a status report.

This status report can correspond to:

The 返回 statement can be used in:
18版本和更高版本
WinDevWindows Store apps This feature is available in Windows Store apps mode.
18新版本
WinDevWindows Store apps This feature is available in Windows Store apps mode.
WinDevWindows Store apps This feature is available in Windows Store apps mode.
例子
// Call to a procedure that returns NOTHING if a problem occurs
// Different process according to the return value
Control_Value字符串型
Control_ValueMyProcessControl_Name
如果Control_Value"Nothing",那么
信息"No value was calculated"
否则
信息"Value of the control: "+Control_Value
结束

// -- Procedure MyProcess
过程MyProcessControl
如果Control..类型=类型.文本型输入框,那么
发送回Control..值
否则
发送回"Nothing"
结束

语法

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).
  • 19版本和更高版本
    You have the ability to return several values. See Multiple return values for more details.
    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 the window or page 隐藏详细信息

 返回 <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.
  • 19版本和更高版本
    You have the ability to return several values. See Multiple return values for more details.
    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 隐藏详细信息

 返回 <Value to Return>

Notes:
  • In this case, <Value to Return> must correspond to the expected value during the call to the window, to the page or to the report.
  • 19版本和更高版本
    You have the ability to return several values. See Multiple return values for more details.
    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 the project 隐藏详细信息

 返回 <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 启动应用程序.

注意

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
19版本和更高版本
Note: These statements can also return several values. See Multiple return values for more details.
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:关闭 is used to exit from the loop (or procedure) and to close the current window.

Caution: 返回 statement and 返回 cannot be used in the same process.

Types returned

15版本和更高版本
From version 15, the following types can be used:
  • structure
  • dynamic structure
  • class
  • advanced type
  • array
  • associative array
  • queue
  • stack
  • list
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

WinDevWindowsLinux用户代码(MCU)

Multiple return values

19版本和更高版本
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
过程MyProc()

// Process
发送回(123


// Code for calling the procedure
xyz)=MyProc()
// x is set to 1, y to 2 and z to 3

Note:
  • For a window, 关闭 can also be used to return several values.
  • In a procedure, all the 返回 or 返回 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 can choose to read just one of them. For example:
    • Reading all the values:
      xyz)=MyProc()
    • Reading a single value:
      x)=MyProc()
      or:
      20版本和更高版本
      xMyProc()
      20新版本
      xMyProc()
      xMyProc()
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 the return values.You have the ability to assign a type to the return values from version 190040.

Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.

Example:

过程f()
发送回(12

过程gxy
发送回x+y

z整数型
zgf())
// z is set to 3
19新版本
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
过程MyProc()

// Process
发送回(123


// Code for calling the procedure
xyz)=MyProc()
// x is set to 1, y to 2 and z to 3

Note:
  • For a window, 关闭 can also be used to return several values.
  • In a procedure, all the 返回 or 返回 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 can choose to read just one of them. For example:
    • Reading all the values:
      xyz)=MyProc()
    • Reading a single value:
      x)=MyProc()
      or:
      20版本和更高版本
      xMyProc()
      20新版本
      xMyProc()
      xMyProc()
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 the return values.You have the ability to assign a type to the return values from version 190040.

Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.

Example:

过程f()
发送回(12

过程gxy
发送回x+y

z整数型
zgf())
// z is set to 3
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
过程MyProc()

// Process
发送回(123


// Code for calling the procedure
xyz)=MyProc()
// x is set to 1, y to 2 and z to 3

Note:
  • For a window, 关闭 can also be used to return several values.
  • In a procedure, all the 返回 or 返回 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 can choose to read just one of them. For example:
    • Reading all the values:
      xyz)=MyProc()
    • Reading a single value:
      x)=MyProc()
      or:
      20版本和更高版本
      xMyProc()
      20新版本
      xMyProc()
      xMyProc()
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 the return values.You have the ability to assign a type to the return values from version 190040.

Multiple return value used in parameter
A multiple return value can be passed in parameter to a WLanguage procedure or function.

Example:

过程f()
发送回(12

过程gxy
发送回x+y

z整数型
zgf())
// z is set to 3