pjs.lr()
This API requires Profound.js version 7.20.0 or later.
Description
This API, when used after the call of a Profound.js module, returns a Boolean value based on the flags["LR"] value of the called Profound.js module.
There is no support for returning the LR indicator value of a called RPG program.
Return Value
A Boolean:
true - The called Profound.js module ended with
flags["LR"]set to true.false - The called Profound.js module ended with
flags["LR"]set to false, or does not contain anyflagsvariable (indicators).
Examples
Example 1: Checking the LR Flag of a Called Module
Consider a simple scenario of a Profound.js module A (moduleA) calling a Profound.js module B (moduleB). In moduleA, the constant moduleB_LR_flag is set to true if moduleB ends with flags["LR"] set to true.
Module A
function moduleA() {
// Call the module whose LR state we want to inspect.
pjs.call("moduleB");
// pjs.lr() reports the LR flag of the module that was called most recently,
// and resets the stored value once it has been read. Read it immediately
// after the call, and read it only once per called module.
const moduleB_LR_flag = pjs.lr();
if (moduleB_LR_flag) {
console.log('Module B ended with flags["LR"] set to true');
}
else {
console.log('Module B ended with flags["LR"] set to false');
}
}
module.exports.run = moduleA;Module B
function moduleB() {
console.log("Module B was called");
// Add custom code here...
// Setting the LR indicator is what pjs.lr() reports back to the caller.
flags["LR"] = true;
}
module.exports.run = moduleB;Example 2: RPG Equivalent
This fixed-form RPG line of code shows a CALL operation. It has indicator 93 in positions 75-76 (the LR indicator).
Fixed-Form RPG
C CALL 'TEST' 93Profound.js Equivalent
test();
flags[93] = pjs.lr();