|
|
|
|
|
|
|
|
|
|
ArraySeek (Function) In french: TableauCherche Seeks the index of an element in a WLanguage array. The following searches can be performed: - Search for an element in a one-dimensional array of simple elements.
- Search for an element in a two-dimensional array of simple elements using a column.
- Search for an element in a two-dimensional array of simple elements using multiple columns.
- Search for an element in a one-dimensional array of structures or classes.
 Search for an element in an array of records. - Search for an object in an array.
Remarks: - This function is equivalent to Seek.
In PHP, the search cannot be performed in an array containing more than one dimension or in an array of structures.
tabMonTableau is array of 0 string
ArrayAdd(tabMonTableau, "WINDEV")
ArrayAdd(tabMonTableau, "WEBDEV")
ArrayAdd(tabMonTableau, "WINDEV et WEBDEV")
ResIndice is int
ResIndice = ArraySeek(tabMonTableau, asLinearFirst, "WINDEV")
Info("La chaîne WINDEV est à l'indice : " + ResIndice)
Syntax
Search for an element in a one-dimensional array of simple elements Hide the details
<Result> = ArraySeek(<WLanguage array> , <Type of search> , <Search value> [, <Start index>])
<Result>: Integer - Index of the sought element,
- -1 if the element is not found in the array.
<WLanguage array>: Array Name of the Array variable to use. This array must be a one-dimensional array. This array can also correspond to a one-dimensional array associated with a property of an advanced variable. <Type of search>: Integer constant Type of search to perform: | | | asBinary | Binary search. This search mode is fast but it must be used on an array sorted in ascending order, without duplicates. Search options (lexicographical order, ignore punctuation, etc.) must be exactly the same for the search (ArraySeek) and for the sort (ArraySort). | | asLinear | Linear search. The search starts:- from the first element.
- from the value of the parameter <Start index>.
The search stops at the first element found. | | asLinearFirst | Linear search from the first element. <Start index> is ignored when this constant is specified. | | asLinearLast | Linear search from the last element. This constant must not be used if <Start index> is specified. | | asLinearNext | Linear search for the next element. This search is performed from the current position or the value of <Start index>. | | asLinearPrevious | Linear search for the previous element. This search is performed from the current position or the value of <Start index>. |
The type of search can be combined with one or more search options:
| | | tccIgnoreAccent | Accent-insensitive search. This option can only be used on arrays of strings.
| | tccIgnoreCase | Case-insensitive search. This option can only be used on arrays of strings. | | tccIgnoreInsideSpace | Search ignoring spaces inside strings. This option can only be used on arrays of strings. | | tccIgnorePunctuationAndSpace | Search ignoring spaces and punctuation. This option can only be used on arrays of strings.
| | tccIgnoreSpace | Search ignoring spaces at the beginning and end of strings. This option can only be used on arrays of strings. | | tccLexicographicOrder | Array sorted linguistically. This option is only useful for binary search and has no effect on linear searches. This option can only be used on arrays of strings.
| | tccRespectNumeric | Array sorted by numeric values. This option is only useful for binary search and has no effect on linear searches. This option can only be used on arrays of strings.
|
For a dichotomous search, the search options must be exactly the same as the options that were used to sort the array (see ArraySort). <Search value>: Any type Value of the element with the desired index. <Start index>: Optional integer Start position for the search (linear search only). This parameter is not required for a binary search.
Searching for an element in a two-dimensional array of simple elements using a column Hide the details
<Result> = ArraySeek(<WLanguage array> , <Type of search> , <Column> , <Search value> [, <Start index>])
<Result>: Integer - Index of the sought element,
- -1 if the element is not found in the array.
<WLanguage array>: Array Name of the Array variable to use. This array must be a two-dimensional array.This array can also correspond to a two-dimensional array associated with a property of an advanced variable (for example, sorting a variable of type xlsDocument according to the values of a column). <Type of search>: Integer constant Search to perform: | | | asBinary | Binary search. This search mode is fast, but it must be used on an array sorted in ascending order, without duplicates and by using exactly the same search options as those used for sorting (ArraySort). | | asLinear | Linear search. The search starts:- from the first element.
- from the value of the parameter <Start index>.
The search stops at the first element found. | | asLinearFirst | Linear search from the first element. This constant must not be used if <Start index> is specified. | | asLinearLast | Linear search from the last element. This constant must not be used if <Start index> is specified. | | asLinearNext | Linear search for the next element. This search is performed from the current position or the value of <Start index>. | | asLinearPrevious | Linear search for the previous element. This search is performed from the current position or the value of <Start index>. |
The type of search can be combined with one or more search options: | | | tccIgnoreAccent | Accent-insensitive search. This option can only be used on arrays of strings.
| | tccIgnoreCase | Case-insensitive search. This option can only be used on arrays of strings. | | tccIgnoreInsideSpace | Search ignoring spaces inside strings. This option can only be used on arrays of strings. | | tccIgnorePunctuationAndSpace | Search ignoring spaces and punctuation. This option can only be used on arrays of strings.
| | tccIgnoreSpace | Search ignoring spaces at the beginning and end of strings. This option can only be used on arrays of strings. | | tccLexicographicOrder | Array sorted linguistically. This option is only useful for binary search and has no effect on linear searches. This option can only be used on arrays of strings.
| | tccRespectNumeric | Array sorted by numeric values. This option is only useful for binary search and has no effect on linear searches. This option can only be used on arrays of strings.
|
For a dichotomous search, the search options must be exactly the same as the options that were used to sort the array (see ArraySort). <Column>: Integer or character string - Simple array: Index of the column to be searched.
- Advanced array: Property to be used for the search. It is also possible to use chained properties (e.g. "Border.Color").
<Search value>: Any type Value of the element with the desired index or property. <Start index>: Optional integer Start position for the search (linear search only). This parameter is not required for a binary search.
Searching for an element in a two-dimensional array of simple elements using multiple columns Hide the details
<Result> = ArraySeek(<WLanguage array> , <Type of search> , <Columns> , <Search value 1> [, <Search value 2> [... [, <Search value N>]]] [, <Start index>])
<Result>: Integer - Index of the sought element,
- -1 if the element is not found in the array.
<WLanguage array>: Array Name of the Array variable to use. This array must be a two-dimensional array.
This array can also correspond to a two-dimensional array of an advanced type (sort performed on a variable of type xlsDocument according to the values of one or more columns for example). <Type of search>: Integer constant Search to perform. Binary search is not available. | | | asLinear | Linear search. The search starts:- from the first element.
- from the value of the parameter <Start index>.
The search stops at the first element found. | | asLinearFirst | Linear search from the first element. This constant must not be used if <Start index> is specified. | | asLinearLast | Linear search from the last element. This constant must not be used if <Start index> is specified. | | asLinearNext | Linear search for the next element. This search is performed from the current position or the value of <Start index>. | | asLinearPrevious | Linear search for the previous element. This search is performed from the current position or the value of <Start index>. | The type of search can be combined with one or more search options: | | | tccIgnoreAccent | Accent-insensitive search. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings.
| | tccIgnoreCase | Case-insensitive search. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings. | | tccIgnoreInsideSpace | Search ignoring spaces inside strings. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings. | | tccIgnorePunctuationAndSpace | Search ignoring spaces and punctuation. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings.
| | tccIgnoreSpace | Search ignoring spaces at the beginning and end of strings. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings. | | tccLexicographicOrder | Array sorted linguistically. This option is only useful for binary search and has no effect on linear searches. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings.
| | tccRespectNumeric | Array sorted by numeric values. This option is only useful for binary search and has no effect on linear searches. This option is applied to all columns on which the search is performed. This option is useful for arrays of strings.
|
For a binary search, the search options must be exactly the same as those used to sort the array (see ArraySort). <Columns>: Character string - Simple array: List of columns to be searched. The different columns must be separated by a semicolon. For example, "2;3" to search on columns 2 and 3.
- Advanced array: List of properties to be used for the search. The properties must be separated by a semicolon.
<Search value 1>: Any type Value of the element with the desired index or property. A value must be indicated for each column or property specified in <Columns>. <Search value 2>: Any optional type Value of the element with the desired index or property. A value must be indicated for each column or property specified in <Columns>. <Search value N>: Any optional type Value of the element with the desired index or property. A value must be indicated for each column or property specified in <Columns>. <Start index>: Optional integer Start position for the search (linear search only). This parameter is not required for a binary search.
Search for an element in a one-dimensional array of structures, classes, advanced types or records. Hide the details
<Result> = ArraySeek(<WLanguage array> , <Type of search> , <Search members> [, <Search value 1> [, <Search value 2> [... [, <Search value N>]]]] [, <Start index>])
<Result>: Integer - Index of the sought element,
- -1 if the element is not found in the array.
<WLanguage array>: Array Name of the Array variable to use. This array must be a one-dimensional array. This array can be: - an array of classes,
- an array of structures,
No search can be performed in an array of structures. - an array of advanced types,
 an array of records.
<Type of search>: Integer constant Type of search to perform:
| | | asBinary | Binary search. This search mode is fast, but it must be used on an array sorted in ascending order, without duplicates and by using exactly the same search options as those used for sorting (ArraySort). This search mode can also be used when performing a search on a single member. | | asLinear | Linear search. The search starts:- from the first element.
- from the value of the parameter <Start index>.
The search stops at the first element found. | | asLinearFirst | Linear search from the first element. This constant must not be used if <Start index> is specified. | | asLinearLast | Linear search from the last element. This constant must not be used if <Start index> is specified. | | asLinearNext | Linear search for the next element. This search is performed from the current position or the value of <Start index>. | | asLinearPrevious | Linear search for the previous element. This search is performed from the current position or the value of <Start index>. |
The type of search can be combined with one or more search options: | | | tccIgnoreAccent | Accent-insensitive search. This option is applied to all members on which the search is performed. This option is only useful for String members.
| | tccIgnoreCase | Case-insensitive search. This option is applied to all members on which the search is performed. This option is only useful for String members. | | tccIgnoreInsideSpace | Search ignoring spaces inside strings. This option is applied to all members on which the search is performed. This option is only useful for String members. | | tccIgnorePunctuationAndSpace | Search ignoring spaces and punctuation. This option is applied to all members on which the search is performed. This option is only useful for String members.
| | tccIgnoreSpace | Search ignoring spaces at the beginning and end of strings. This option is applied to all members on which the search is performed. This option is only useful for String members. | | tccLexicographicOrder | Array sorted linguistically. This option is only useful for binary search and has no effect on linear searches. This option is applied to all members on which the search is performed. This option is only useful for String members.
| | tccRespectNumeric | Array sorted by numeric values. This option is only useful for binary search and has no effect on linear searches. This option is applied to all members on which the search is performed. This option is only useful for String members.
|
For a dichotomous search, the search options must be exactly the same as the options that were used to sort the array (see ArraySort). <Search members>: Character string - Structures and classes: Names of the search members. To search for multiple members, separate their names using semicolons. It is also possible to chain the members to be searched using "." or ":" between the members. You can also perform a search in the properties of a class.
- Advanced types: Names of the search properties. To search for multiple properties, separate their names using semicolons. It is also possible to chain the properties to be searched using "." or ":" between the properties. For example, "Border.Color".
- Records: Names of the search items. To search for multiple items, separate their names using semicolons. It is also possible to chain the items to be searched using "." or ":" between the properties.
<Search value 1>: Any type Value of the element with the desired member or property. A value must be indicated for each member specified in <Search members>. <Search value 2>: Any optional type Value of the element with the desired member or property. A value must be indicated for each member specified in <Search members>. <Search value N>: Any optional type Value of the element with the desired member or property. A value must be indicated for each member specified in <Search members>. <Start index>: Optional integer Start position for the search (linear search only). This parameter is not required for a binary search.
Searching for the index of an object in a one-dimensional array (data binding syntax) Hide the details
<Result> = ArraySeek(<WLanguage array> , <Type of search> , <Search object>)
<Result>: Integer - Index of the sought object,
- -1 if the object is not found in the array.
<WLanguage array>: Array Name of the Array variable to use. This array must be a one-dimensional array. This array can be an array of classes, dynamic classes, structures, dynamic structures, advanced types and dynamic advanced types. <Type of search>: Integer constant Type of search to perform:
<Search object>: Any type Instance of the search object.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|