PC SOFT

WINDEV的在线文档

  • Equivalence
  • Filter (syntaxes 2)
  • Exiting from FOR EACH loop
  • Influence of the mode for exiting from the loop on the automatic browse of data files
  • Running the next iteration
  • Modifying the key used for the automatic browse of data files or queries
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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本地访问

The 对于每个 statement is used to perform different types of HFSQL browse:
  • Full browse (according to a specified key or not)
  • Browse with filter (simple filter, filter on a key or filter on the search key). In this case, the filters accept the operators of H过滤器.
The browse operations can be performed on a data file, a view, a query or a data source. The records locked in read/write are not read.

Notes:

  • If the key given to the 对于每个 statement is the key that was previously returned by H过滤器, the filter will be respected.
  • The FOR ALL, FOR EACH statements are accepted. The 对于每个 statement will be used in this documentation but it can be replaced by FOR ALL.
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.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
例子
// Syntax 1
对于每个Customer
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Syntax 1
对于每个Customer根据CustomerNum
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Syntax 2
// Browse with filter
对于每个Customer满足"CustomerCity = 'Montpellier'"
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

City"Lyon"
对于每个Customer满足"CustomerCity = '"+City+"' and CustomerAge >= 21"
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Syntax 2
// Browse with filter on a specific key
对于每个Customer根据CustomerNum满足"CustomerCity = 'Montpellier'"
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

City"Lyon"
对于EACHCustomer满足"CustomerCity = '"+City+"'"并且...
"CustomerAge >= 21"当有CustomerNum
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Syntax 3
// Comparison according to a value
对于每个Customer满足CustomerName等于"Doe"
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Comparison according to a value
对于每个Orders满足OrderDate等于"20031231"
// Add orders into the List Box control
列表添加LIST_OrderListOrder.OrderNum
结束

// Syntax 3
// Comparison according to a set of values
对于EACHOrders满足OrderDate"20030101"直到"20031231"
// Add orders into the List Box control
列表添加LIST_OrderListOrder.OrderNum
结束

// Comparison according to a set of values
对于EACHOrders满足"20030101"小于等于OrderDate小于等于"20031231"
// Add orders into the List Box control
列表添加LIST_OrderListOrder.OrderNum
结束

// Syntax 4
// Browse with filter on a specific key
对于每个Customer满足CityCustomer开始于"Mont"从尾部
// Add customers into the List Box control
列表添加LIST_CustomerListCustomer.CustomerNum
结束

// Syntax 5
// Browse with filter on a composite key
对于每个ContactFile满足CCState等于【"Prospect"69
// Add contacts into the List Box control
列表添加LIST_ContactListContactFile.ContactNum
结束

// Browse with filter on a composite key
对于每个ContactFile满足CZipCode开始于【"Prospect"69
// Add contacts into the List Box control
列表添加LIST_ContactListContactFile.ContactNum
结束

语法

1 - Full browse 隐藏详细信息

 1. Full browse according to the best search key

Caution: Modifying the file in the analysis (adding a key item for example) can modify the search key used.

FOR EACH <File> [<Direction>]
...
END

2. Full browse according to the key passed in parameter

FOR EACH <File> ON <Key item> [<Direction>]
...
END

<FOR EACH>:
Marks the beginning of the statement block.
<File>:
Name of the HFSQL data file, view or query to browse.
<ON>:
Defines the type of browse.
<Key Item>:
Name of the key item used to browse the HFSQL data file (view or query).
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browses the data file from the first element to the last one.
从尾部Browses the data file from the last element to the first one.
<END>:
Marks the end of the statement block.

2 - Browse with filter 隐藏详细信息

 1. Browse with filter (the best search key is automatically defined)

Caution: Modifying the file in the analysis (adding a key item for example) can modify the search key used.

FOR EACH <File> WHERE "<1st Condition>
               [AND/OR/NOT <2nd Condition>
               [AND/OR/NOT...<Nth Condition>]]" [<Direction>]
...
END

2. Browse with filter according to the specified key

FOR EACH <File> WHERE "<1st Condition>
               [AND/OR/NOT <2nd Condition>
               [AND/OR/NOT...<Nth Condition>]]" [<Direction>]
...
ON <Key Item>
END

<FOR EACH>:
Marks the beginning of the statement block.
<File>:
Name of the HFSQL data file, view or query to browse.
<WITH>:
Defines the type of browse.
<Nth condition>:
Nth condition of the filter for the HFSQL browse. See notes for more details.
<AND/OR/NOT>:
Optional logical operators used to combine the different filter conditions.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browses the data file from the first element to the last one.
从尾部Browses the data file from the last element to the first one.
<Key Item>:
Item corresponding to a key of the data file. The filter will be performed on this key.
<END>:
Marks the end of the statement block.

3 - Browse with selection filter on the search key 隐藏详细信息

 1. Comparison filter according to a value

FOR EACH <File> ON <Key Item> [ = / <= / >= ] <Value> [<Direction>]
...
END

2. Comparison filter according to an interval of values

FOR EACH <File> WHERE <Key item> = <Minimum value> TO <Maximum value> [<Direction>]
...
END

FOR EACH <File> WHERE <Minimum value> <= <Key item> <= <Maximum value> [<Direction>]
...
END

<FOR EACH>:
Marks the beginning of the statement block.
<File>:
Name of the HFSQL data file, view or query to browse.
<WITH>:
Defines the type of browse.
<Key Item>:
Key item of the data file to browse.
<Value>:
Comparison value of the key item.
<Minimum value>, <Maximum value>:
Comparison value of the key item.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browses the data file from the first element to the last one.
从尾部Browses the data file from the last element to the first one.
<END>:
Marks the end of the statement block.

4 - Browse with "Start with" generic search, ascending or descending 隐藏详细信息

 对于 EACH <File> WHERE <Key Item> [= <Beginning of Sought Value> [<Direction>]
...
END

<FOR EACH>:
Marks the beginning of the statement block.
<File>:
Name of the HFSQL data file, view or query to browse.
<WITH>:
Defines the type of browse.
<Key Item>:
Key item of the data file to browse.
<Beginning of Sought Value>:
Comparison value of the key item.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browses the data file from the first element to the last one.
从尾部Browses the data file from the last element to the first one.
<END>:
Marks the end of the statement block.

5 - Browse with filter on a composite key 隐藏详细信息

 1. Exact-match search

FOR EACH <File> WHERE <Composite Key> = [<Value of Component 1>, ..., <Value of Component N>] [<Direction>]
...
END

2. Generic search ("Starts with")

FOR EACH <File> WHERE <Composite Key> [= [<Value of Component 1>, ..., <Value of Component N>] [<Direction>]

...
END

<FOR EACH>:
Marks the beginning of the statement block.
<File>:
Name of the HFSQL data file or view to browse.
<WITH>:
Defines the type of browse.
<Composite Key>:
Composite key of the data file to browse.
<Value of Component N>:
Value of the component.
<Direction>:
Optional indicator for the browse direction:

从头部
(default value)
Browses the data file from the first element to the last one.
从尾部Browses the data file from the last element to the first one.
<END>:
Marks the end of the statement block.

注意

Equivalence

  • The syntax FOR EACH <File> WHERE <Item> = <Value> is equivalent to a browse performed on the data file by H读查找. This browse takes the filters previously defined on the data file into account.
  • The syntax FOR EACH <File> WHERE <Condition> is used to define a filter and to browse the data file. This browse ignores the filters that were defined beforehand.

Filter (syntaxes 2)

The general syntax of a filter has the following format:

"<Item Name> <Operators> <Item Value>"

For example:

"CustomerName > 'Smith' and Zip = 75 or CustomerAge >= 32"

The supported operators depend on the type of the items used in the condition:

<>DifferentValid for all the types
>Greater thanValid for all the types
>= Greater than or equal toValid for all the types
<Less thanValid for all the types
<= Less than or equal toValid for all the types
=Strictly equal toValid for all the types
~= Almost equal toValid for the "string" types only
]ContainsValid for the "string" types only
]= Starts withValid for the "string" types only

Notes:
  • The constant strings must be enclosed in simple quotes. For example: "CustomerName = '"+Customer+"'"
  • <Item Name> must only contain letters, digits and underscore characters ("_"). If <Item name> contains other characters (quote, ...), the name of the item must be enclosed in double quotes. For example: "e_mail@"]'fr'
  • The comparisons between strings are performed according to the ASCII value of the characters and not according to the lexicographic value ('a' > 'Z').
  • The binary memos and the composite keys cannot be part of an <Item Value>.
  • If <Item value> contains a simple quote (or a double quote), this simple quote (or double quote) must be preceded by a backslash character.

Exiting from FOR EACH loop

Several statements are available:
  • 返回 statement: Exit from the 对于每个 loop and exit from the current process (or procedure).
  • 返回 statement: Return a status report to the calling process. Exit from the 对于每个 loop and exit from the current process (or procedure).
  • 跳出 statement/"跳出:" label: Exits from the 对于每个 loop and runs the rest of the current process.
关闭 is used to exit from the 对于每个 loop and to close the current window.

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

Influence of the mode for exiting from the loop on the automatic browse of data files

  • If the browse ends automatically:
    • The position in the data file before the browse is restored.
    • The possible filter required for the browse is disabled.
  • If the browse is interrupted (BREAK, RETURN, RESULT, Close, ...):
    • The position in the data file before the browse is not restored.
    • The possible filter required for the browse is not disabled. It must be disabled manually (H禁用过滤器).

Running the next iteration

To directly run the next iteration without ending the code of the current iteration, use the 继续 statement / "继续:" label statement:

// Browse FileName in the order of KeyItem
对于每个FileName根据KeyItem
...
如果Condition,那么继续 // Return to the FOR EACH keyword
// and go to the next record
...
结束

Modifying the key used for the automatic browse of data files or queries

If the value of the search item is modified when browsing a data file (or a query), some records may be browsed several times.

Indeed, the modification of the search item updates the index key of the file. This modification is taken into account during the automatic reading of the next records.

This remark is also valid for the automatic browse of a sorted query (ORDER BY) without search key.

// Browse FileName on KeyItem
对于每个FileName根据KeyItem
...
如果Condition,那么
// Modify the value of the search key
FileName.KeyItem"New value"
H修改FileName

结束
// If the new value of the search key
// positions on the record after in the browse order
// the record will be read again during the browse.
...
结束