Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Lookup This API allows you to find an array element which matches (or is close to) an argument you pass to the lookup function. This API will return the index of the value if it has found a match, otherwise it will return 0.

Parameters

...

it.

An optional resulting indicators object can specify if any elements in the flags array should be set. The resulting indicators object can have these properties:

  • equal (Number) - identifies the flag number to set if an exact match is found
  • low (Number) - identifies the flag number to set if the nearest lower entry is found
  • high (Number) - identifies the flag number to set if the nearest higher entry is found
Parameters
  1. Search argument
  2. Array
  3. Start index (OR resulting indicators object)
  4. Resulting indicators object (optional)
  5. Search type (optional) -  String value of "LE", "LT", "GE", or "GT" can specify a less than or equal to, a less than, a greater than or equal to, or a greater than search instead of an exact match search
Return Value

Returns 0 if no matching element is found; otherwise, the element index is returned.

Example
Code Block
languagejavascript
pjs.define("i", { type: 'integer', length: 3, decimals: 0 });  
pjs.define("SRCHWD", { type: 'charpacked decimal', length: 152, decimals: 0 });
pjs.define("arr", { type: 'char', length: 15, dim: 10 });

arr[1] = 'Cornwall';
arr[2] = 'kingston';
arr[3] = 'London';
arr[4] = 'Paris';
arr[5] = 'Scarborough';
arr[6] = 'York';
arr[7] = 'Columbus';
arr[8] = 'Dayton';
arr[9] = 'centerville';
arr[10] = 'vasad';

SRCHWD = 'York'arr[6];

i = pjs.lookup(SRCHWD, arr, nulli, SRCHWD);
//i = 6 { equal: 26 });


RPG Equivalent

%LOOKUP(), LOOKUP