Seeks an element in a one-dimensional WLanguage array by using a comparison procedure.

Versions 18 and later

This function is now available for iPhone/iPad applications.

New in version 18

This function is now available for iPhone/iPad applications.

This function is now available for iPhone/iPad applications.

Versions 19 and later

This function is now available for Windows Mobile applications.

New in version 19

This function is now available for Windows Mobile applications.

This function is now available for Windows Mobile applications.

Versions 21 and later

This function is now available in Apple Watch mode.

This function is now available in browser code.

This function is now available in Universal Windows 10 App mode.

New in version 21

This function is now available in Apple Watch mode.

This function is now available in browser code.

This function is now available in Universal Windows 10 App mode.

This function is now available in Apple Watch mode.

This function is now available in browser code.

This function is now available in Universal Windows 10 App mode.

Versions 22 and later

This function is now available in Android Widget mode.

This function is now available for Android applications.

This function is now available for Java applications.

New in version 22

This function is now available in Android Widget mode.

This function is now available for Android applications.

This function is now available for Java applications.

This function is now available in Android Widget mode.

This function is now available for Android applications.

This function is now available for Java applications.

Example

// Create an array of references arrReference is array of strings // Find a reference identified by its first 6 characters nIndex is an integer nSubscript = arrReference.SeekByProcedure(ProcCompareShortReference, ... asLinear, 0, "123456")

// ProcCompareShortReference procedure INTERNAL PROCEDURE ProcComparisonReferenceShort(ItemSearched, Search) // We compare the first 6 characters of the array elements // with the sought reference RESULT StringCompare(Left(SoughtElement, 6), Search) END

Syntax

<Result> = <WLanguage array>.SeekByProcedure(<WLanguage procedure> , <Type of search> [, <Start subscript> [, <Sought value 1> [... [, <Sought value N>]]]])

<Result>: Integer

Subscript of element found in the array.

<WLanguage array>: Array

Name of Array variable where the search will be performed. This array must be a one-dimensional array.

<WLanguage procedure>: Procedure name

WLanguage comparison procedure. See the remarks for more details.

<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 with the same comparison procedure or with an equivalent procedure (see <Array variable>.Sort).

asLinear

Linear search. The search starts:

from the first element if <Start subscript> is set to 0,

from <Start subscript>.

The search stops as soon as an element is found.

asLinearLast

Linear search from the last element. This constant must not be used if <Start subscript> is specified.

asLinearPrevious

Linear search for the previous element. This search is performed from the current position or the value of <Start subscript>.

asLinearFirst

Linear search from the first element. <Start subscript> is ignored when this constant is specified.

asLinearNext

Linear search for the next element. This search is performed from the current position (if <Start subscript> is set to 0) or from the position specified by <Start subscript>.

<Start subscript>: Optional integer

Start position for the search (linear search only). This parameter is not required for a binary search.

<Sought value 1>: Any type

Value of sought element.

<Sought value N>: Any type

Value of sought element.

Remarks

WLanguage comparison procedure

This procedure is called as many times as necessary.

The first parameter of the procedure corresponds to the array element to compare. The other parameters are the search values passed in parameter to <Array>.SeekByProcedure.

The comparison procedure must return the following values:

If the array element is too small in relation with the search values, the procedure must return -1.

If the array element is too large in relation with the search values, the procedure must return 1.

If the array element corresponds to the search values, the procedure must return 0.

Caution: for the dichotomous search, the comparison procedure must return the following values:

If the array element is too small in relation to the search values, the procedure must return 1.

If the array element is too large in relation to the search values, the procedure must return -1.

If the array element corresponds to the search values, the procedure must return 0.