pjs.tableLookup()

pjs.tableLookup()

Description

This API finds an element in a table array and positions the table to that element.

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 - Value to search for.

  2. Table array - The table to search.

  3. Alternate table array (optional) - An alternating table to position along with the search table (OR the resulting indicators object).

  4. Resulting indicators object (optional) - Flag numbers to set, as described above.

  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.

Examples

Example 1
pjs.define("tab1", { type: 'char', length: 2, dim: 5, table: true, initValue: [ '01', '02', '03', '04', '05' ] }); pjs.define("output", { type: 'char', length: 52, varying: true }); if (pjs.tableLookup('02', tab1)) { pjs.clear(tab1); output = 'Cleared. '; if (pjs.tableLookup('03', tab1)) { output += 'Other entries still there.'; } }
Example 2
pjs.define("var1", { type: 'decimal', length: 2, decimals: 0, initValue: 4 }); pjs.define("var2", { type: 'decimal', length: 2, decimals: 0, initValue: 20 }); pjs.define("tabsearch", { type: 'decimal', length: 2, decimals: 0, dim: 10, table: true, initValue: [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 ] }); pjs.tableLookup(var1, tabsearch, { equal: 71 }); pjs.tableLookup(var2, tabsearch, { equal: 72 }); if (flags[71] && !flags[72]) { //var1 value found, var2 value not found }
Example 3
pjs.define("var1", { type: 'decimal', length: 2, decimals: 0, initValue: 4 }); pjs.define("tabsearch", { type: 'decimal', length: 2, decimals: 0, dim: 10, table: true, orderby: 'ASCEND', initValue: [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 ] }); pjs.tableLookup(var1, tabsearch, { equal: 66 }); console.log(pjs.equal());

RPG Equivalent

%TLOOKUP()


Related Pages