# BinarySearch

Jump to navigation
Jump to search

Perform a binary search over the range First Index to Last Index. Assumes the data compared is sorted ascending and the comparison is for equality. Multiple comparisons can be combined only with AND. Returns 1 + last index or 0 if Zero On Fail is set.

$R = BinarySearch($F,$1,$2,$3)$R = Result $1 = First Index $2 = Last Index $3 = Zero On Fail $F = Condition

The first part of the condition must be the search space ie.

r.row = BinarySearch(t.table1[r.row][c.column] == r.column_value, 1, t.table1.RowCount, 1)

If you express the condition in reverse it will not work ie.

r.row = BinarySearch(r.column_value == t.table1[r.row][c.column], 1, t.table1.RowCount, 1)