Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/ProgramCall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ ProgramCall API
.. autofunction:: returnConfig
.. autofunction:: data

Example
Examples
^^^^^^^^

Call the QUSROBJD Program
"""""""""""""""""""""""""

.. literalinclude:: examples/qusrobjd.js
:language: javascript

Retrieve the Return Value From a Service Program
""""""""""""""""""""""""""""""""""""""""""""""""

.. literalinclude:: examples/cosine.js
:language: javascript

27 changes: 27 additions & 0 deletions docs/examples/cosine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { Connection, ProgramCall } = require('itoolkit');
const { parseString } = require('xml2js');

const conn = new Connection({
transport: 'ssh',
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
});

const program = new ProgramCall('QC2UTIL2', { lib: 'QSYS', func: 'cos' });

program.addParam({ type: '8f', value: '0' });
program.addReturn({ type: '8f', value: '' });

conn.add(program);
conn.debug(true);

conn.run((error, xmlOutput) => {
if (error) {
throw error;
}
parseString(xmlOutput, (parseError, result) => {
if (parseError) {
throw parseError;
}
console.log(result.myscript.pgm[0].return[0].data[0]._); // 1
});
});