PC SOFT

WINDEV的在线文档

  • Syntax 1: Browsing the array elements
  • Syntax 2: Browsing the values of array elements
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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 perform different types of browse operations on the arrays:
  • Browsing the array elements,
  • Browsing the values of array elements.
Note: The FOR ALL, FOR EACH statements are accepted. In this documentation, we will be using the 对于每个 statement but it can be replaced by FOR ALL.

15版本和更高版本
The FOR EACH statement can also be used to browse the .Net objects that implement the IEnumerable interface.
15新版本
The FOR EACH statement can also be used to browse the .Net objects that implement the IEnumerable interface.
The FOR EACH statement can also be used to browse the .Net objects that implement the IEnumerable interface.

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.
例子
// Browse the elements found in an array of reals and calculate the sum
// Fill the array
ArrCalc浮点型的数组型3
ArrCalc1】=12.5
ArrCalc2】=10
ArrCalc3】=7.5
// Calculate the sum
TotalSum浮点型
对于ArrCalc中的每个元素AnElement
TotalSum+=AnElement
结束

20版本和更高版本
WinDev
// Browse the arrCustomers array and only process the customers
// whose city is equal to "MONTPELLIER".

定义stCustomer结构型
LastName字符串型
FirstName字符串型
City字符串型
结束

arrCustomersstCustomer型的数组型0

对于arrCustomers中的每个元素stACustomer
// Process
结束
20新版本
WinDev
// Browse the arrCustomers array and only process the customers
// whose city is equal to "MONTPELLIER".

定义stCustomer结构型
LastName字符串型
FirstName字符串型
City字符串型
结束

arrCustomersstCustomer型的数组型0

对于arrCustomers中的每个元素stACustomer
// Process
结束
WinDev
// Browse the arrCustomers array and only process the customers
// whose city is equal to "MONTPELLIER".

定义stCustomer结构型
LastName字符串型
FirstName字符串型
City字符串型
结束

arrCustomersstCustomer型的数组型0

对于arrCustomers中的每个元素stACustomer
// Process
结束

语法

Browsing the array elements 隐藏详细信息

 对于 EACH [ELEMENT] <Variable> [, <Key> [, <Counter>]] OF <Array> [WHERE <Condition>] [<Direction>]
    ...
END

<FOR EACH [ELEMENT]>:
Marks the beginning of the statement block. The ELEMENT keyword is optional.
<Variable>:
Variable whose type is identical to the type of the array elements. For the arrays of classes, the variable must be a Dynamic Class variable. There is no need to declare this variable.
<Key>:
Key of the element browsed. This key depends on the element browsed:
  • One-dimensional array: subscript of the element in the array.
  • Two-dimensional array (or n-dimensional array): counter that starts from 1
There is no need to declare this variable.
<Counter>:
Integer variable containing the number of iterations. There is no need to declare this variable.
<Array>:
Array to browse.
<Condition>:
20版本和更高版本
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
20新版本
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browse the array from the first element to the last one.
从尾部Browse the array from the last element to the first one.

Browsing the values of array elements 隐藏详细信息

 对于 EACH [ELEMENT] <Value> OF <Array> [WHERE <Condition>] [<Direction>]
    ...
END

<FOR EACH ELEMENT>:
Marks the beginning of the statement block. The ELEMENT keyword is optional.
<Value>:
Variable whose type is compatible with the array elements. There is no need to declare this variable.
<Array>:
Array to browse.
<Condition>:
20版本和更高版本
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
20新版本
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
WinDev Condition to indicate to filter the browse. Only the array elements corresponding to the filter will be browsed.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browse the array from the first element to the last one.
从尾部Browse the array from the last element to the first one.

注意

Syntax 1: Browsing the array elements

For each iteration, <Variable> directly refers to the current element in the array. If the value of <Variable> is modified, the current element in the array is modified.

When exiting from the loop (standard exit or via the BREAK statement), the value of the last element read is assigned to <Variable> but <Variable> does not directly refer to the array element anymore.

All types of arrays are available: automatic, fixed, dynamic.

The arrays can have several dimensions.

The behavior is undefined if the number of elements is modified in the browse loop.

Syntax 2: Browsing the values of array elements

For each iteration, the value of the element browsed is assigned to the <Value> variable. If the value of <Value> is modified, the current element in the array is not modified.

All types of arrays are available: automatic, fixed, dynamic.

The arrays can have several dimensions.

The behavior is undefined if the number of elements is modified in the browse loop.