Versions Compared

Key

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

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

Parameters
  1. the array object to search in
  2. index to start the search from (can pass null, which defaults to 1)
  3. value to search for

...

Example
Code Block
languagejavascript
pjs.define("i", { type: 'integer', length: 3, decimals: 0 });
pjs.define("SRCHWD", { type: 'char', length: 15 });
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';

i = pjs.lookup(arr, null, SRCHWD);
//i = 6