PC SOFT

WINDEV的在线文档

  • Syntax 1: Browsing the sub-strings separated by a separator
  • Syntax 2 and 3: Browsing the occurrences of a string inside another one
  • FOR EACH STRING, FOR EACH POSITION and UNICODE
  • Tip: How do I retrieve the separator?
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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 browse the strings according to different methods:
  • Browsing the sub-strings separated by a separator.
  • Browsing the occurrences of a string inside another one.
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.
例子
// Retrieves the list of libraries loaded in memory
LibraryList字符串型DLL列表()

// For each library
对于LibraryList中被回车分隔的每个子串ALibrary
// Adds the library into the TABLE_Library table
表格添加行TABLE_Library提取字符串ALibrary1TAB))
结束

// The "C:\MyDocuments\Exports.TXT" file contains the list
// of exported products, separated by ";"
// Retrieve each product
ExportedProduct字符串型文件加载文本"C:\MyDocuments\Exports.TXT"
FormerPosition整数型

// For each product
对于";"中子串ExportedProduct的每个位置CurrentPosition
// Adds the product into ProductList
列表添加LIST_Product,...
ProductExport【【FormerPosition+1直到CurrentPosition-1】】
// Store the position
FormerPositionCurrentPosition
结束

对于"A.B.C"中被"."分隔的每个子串sc1nPositionnCounter
跟踪sc1+" - "+nPosition+" - "+nCounter
结束
// Returns
// A - 1 - 1
// B - 3 - 2
// C - 5 - 3

19版本和更高版本
s字符串型"I am a sentence"+回车+"on several lines"
对于s中被【" "回车】分隔的每个子串s2
跟踪s2
结束

// Returns
// I
// am
// a
// sentence
// on
// several
// lines
19新版本
s字符串型"I am a sentence"+回车+"on several lines"
对于s中被【" "回车】分隔的每个子串s2
跟踪s2
结束

// Returns
// I
// am
// a
// sentence
// on
// several
// lines
s字符串型"I am a sentence"+回车+"on several lines"
对于s中被【" "回车】分隔的每个子串s2
跟踪s2
结束

// Returns
// I
// am
// a
// sentence
// on
// several
// lines

语法

Browsing the sub-strings separated by a separator 隐藏详细信息

 对于 EACH STRING <Sub-string> [, <Position> [, <Counter>]] OF <Initial String>
                                                                   [SEPARATED BY <Separator>] [<Direction>]

    ...
END

<FOR EACH STRING>:
Marks the beginning of the statement block.
<Sub-string>:
String variable containing the text of the sub-string. There is no need to declare this variable.
<Position>:
Integer variable containing the position of the sub-string in the string. There is no need to declare this variable.
<Counter>:
Integer variable containing the number of iterations. There is no need to declare this variable.
<Initial String>:
String containing the full text. The sub-strings are not browsed if this string is empty.
<Separator>:
Optional string containing the separator of sub-strings (TAB by default).

19版本和更高版本
To specify several separators, use the following syntax:

[<Separator1> , ..., <Separator N>]

For example: [TAB, CR]
19新版本
To specify several separators, use the following syntax:

[<Separator1> , ..., <Separator N>]

For example: [TAB, CR]
To specify several separators, use the following syntax:

[<Separator1> , ..., <Separator N>]

For example: [TAB, CR]
<Direction>:
Optional indicator for the browse direction:

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

Browsing the occurrences of a string inside another string 隐藏详细信息

 对于 EACH POSITION <Position> OF <Search> IN <Initial String> [<Direction>]

    ...
END

<FOR EACH POSITION>:
Marks the beginning of the statement block.
<Position>:
Integer variable containing the current position. There is no need to declare this variable.
<Search>:
Sought string.
<Initial String>:
String containing the full text.
<Direction>:
Optional indicator for the browse direction:

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

Browsing the occurrences of a string inside another string 隐藏详细信息

 对于 EACH POSITION <Position> OF <Search> IN <Initial String> WITH <Options>

    ...
END

<FOR EACH POSITION>:
Marks the beginning of the statement block.
<Position>:
Integer variable containing the current position. There is no need to declare this variable.
<Search>:
Sought string.
<Initial String>:
String containing the full text.
<Options>:
Indicator for the selected options (can be combined):

从头部
(default value)
Browse the string from the first character to the last one.
从尾部Browse the string from the last character to the first one.
全字匹配Search for the whole word
忽略大小写Search while ignoring the case (uppercase/lowercase characters)

注意

Syntax 1: Browsing the sub-strings separated by a separator

Browses all the sub-strings of <Initial String> separated by <Separator>. The browse is not performed if <Initial String> is an empty string.

For each iteration:

  • <Sub-string> is filled with the current sub-string.
  • <Position> contains the position of the sub-string inside the string.
  • <Counter> contains the number of iterations performed.
The behavior is undefined if the initial string or the separator is modified during the browse.

Note: If <Initial String> ends with the separator, <Sub-string> returns an empty string at the end. Otherwise, <Sub-string> corresponds to the last checked-out element.

Syntax 2 and 3: Browsing the occurrences of a string inside another one

Browses all the positions of <Search> in <Initial String>.

For each iteration, the <Position> variable is assigned with the position of the current sub-string.

The behavior is undefined if the initial string or the sought string is modified during the browse.

FOR EACH STRING, FOR EACH POSITION and UNICODE

<Sub-string>, <Initial String>, <Separator> and <Search> can correspond to:
  • ANSI strings.
  • UNICODE strings.
However, the ANSI strings and the UNICODE strings cannot be used in the same syntax.

See Managing the UNICODE for more details.

Tip: How do I retrieve the separator?

To retrieve the separator in the loop, use the following syntax that allows you to find out the position of the separator. To find out the separator, all you have to do is retrieve the following character.

For example:

对于sStringIN中被【" ""-"】分隔的每个子串sTempStringnPosition
sSeparatorsStringIN【【nPosition+长度sTempString)】】
...
结束