ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Queue, stack, list and array functions / Array functions
  • WLanguage comparison procedure
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Seeks an element in a one-dimensional WLanguage array by using a comparison procedure.
Remark: This function is equivalent to SeekByProcedure.
Example
// Create an array of references
arrReference is array of strings
// Find a reference identified by its first 6 characters
nIndex is int
nIndex = ArraySeekByProcedure(arrReference, ProcCompareShortReference, ...
asLinear, 0, "123456")
 
// ProcCompareShortReference procedure
INTERNAL PROCÉDURE ProcCompareShortReference(SoughtElement, Search)
// Compare the first 6 characters of the elements in the array
// with the sought reference
RESULT StringCompare(Left(SoughtElement, 6), Search)
END
Syntax
<Result> = ArraySeekByProcedure(<WLanguage array> , <WLanguage procedure> , <Type of search> [, <Start index> [, <Sought value 1> [... [, <Sought value N>]]]])
<Result>: Integer
Index of the element found in the array.
<WLanguage array>: Array
Name of the Array variable where the search will be performed. This array must be a one-dimensional array.
<WLanguage procedure>: Procedure name
WLanguage comparison procedure. For more details, see the remarks.
<Type of search>: Integer constant
Type of search to perform:
asBinaryBinary 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 ArraySort).
asLinearLinear search. The search starts:
  • from the first element if <Start index> is set to 0,
  • from <Start index>.
The search stops as soon as an element is found.
asLinearFirstLinear search from the first element. <Start index> is ignored when this constant is specified.
asLinearLastLinear search from the last element. This constant must not be used if <Start index> is specified.
asLinearNextLinear search for the next element. This search is performed from the current position (if <Start index> is set to 0) or from the position specified by <Start index>.
asLinearPreviousLinear search for the previous element. This search is performed from the current position or the value of <Start index>.
<Start index>: 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 the search element.
<Sought value N>: Any type
Value of the search element.
Remarks

WLanguage comparison procedure

This comparison procedure has the following format:
PROCEDURE <Procedure name>(<Element> , <Sought value 1> [, ... , [<Sought value N>]])
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 as parameter to ArraySeekByProcedure.
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.
Business / UI classification: Neutral code
Component: wd290vm.dll
Minimum version required
  • Version 17
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 02/16/2023

Send a report | Local help