|
%LOOKUPxx (Look Up an Array Element)
%LOOKUP(arg : array {: startindex {: numelems}})
%LOOKUPLT(arg : array {: startindex {: numelems}})
%LOOKUPGE(arg : array {: startindex {: numelems}})
%LOOKUPGT(arg : array {: startindex {: numelems}})
%LOOKUPLE(arg : array {: startindex {: numelems}})
The following functions return the array index of the item in array that
matches arg as follows:
%LOOKUP
An exact match.
%LOOKUPLT
The value that is closest to arg but less than arg.
%LOOKUPLE
An exact match, or the value that is closest to arg but less than arg.
%LOOKUPGT
The value that is closest to arg but greater than arg.
%LOOKUPGE
An exact match, or the value that is closest to arg but greater than arg.
If no value matches the specified condition, zero is returned.
The search starts at index startindex and continues for numelems elements.
By default, the entire array is searched.
The first two parameters can have any type but must have the same type.
They do not need to have the same length or number of decimal positions.
The third and fourth parameters must be non-float numeric values with zero
decimal positions.
For %LOOKUPLT, %LOOKUPLE, %LOOKUPGT, and %LOOKUPGE, the array must be
defined with keyword ASCEND or DESCEND. The ALTSEQ table is used, unless
arg or array is defined with ALTSEQ(*NONE).
Built-in functions %FOUND and %EQUAL are not set following a %LOOKUP
operation.
Note:
Unlike the LOOKUP operation code, %LOOKUP applies only to arrays. To look
up a value in a table, use the %TLOOKUP built-in function.
Figure 197. %LOOKUPxx Example
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
/FREE
arr(1) = 'Cornwall';
arr(2) = 'Kingston';
arr(3) = 'London';
arr(4) = 'Paris';
arr(5) = 'Scarborough';
arr(6) = 'York';
n = %LOOKUP('Paris':arr);
// n = 4
n = %LOOKUP('Thunder Bay':arr);
// n = 0 (not found)
n = %LOOKUP('Kingston':arr:3);
// n = 0 (not found after start index)
n = %LOOKUPLE('Paris':arr);
// n = 4
n = %LOOKUPLE('Milton':arr);
// n = 3
n = %LOOKGT('Sudbury':arr);
// n = 6
n = %LOOKGT('Yorks':arr:2:4);
// n = 0 (not found between elements 2 and 5)
/END-FREE
Peter Vidal
PALL Aeropower Corporation
SR Programmer Analyst
5775 Rio Vista Drive
Clearwater, FL 33760-3137
(727)539-8448
www.pall.com
"My religion consists of a humble admiration of the illimitable superior
spirit who reveals himself in the slight details we are able to perceive
with our frail and feeble mind."
Albert Einstein
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.