Versions Compared

Key

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

Find element in a table array. You can also use pjs.equal() to determine the result of pjs.tableLookup().

Parameters
  1. Search argument
  2. Table array
  3. Alternate table array OR resulting indicators
  4. resulting indicators (if alternate table array has been passed in) OR null
  5. Search type - "LE", "LT". "GE", "GT". Can be null.
Example

 

Code Block
languagejavascript
  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.';
    }
  }
Code Block
languagejavascript
  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
  }
Code Block
languagejavascript
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()