...
Example 1.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function increment() { // x and y must be declared in the parent scope where pjs.import() is used x += 1; y += 2; } exports.increment = increment; |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function decrement() { // x and y must be declared in the parent scope where pjs.import() is used x -= 1; y -= 2; } exports.decrement = decrement; |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function main() { pjs.define("x", { type: "integer" }); pjs.define("y", { type: "integer" }); x = 1; y = 2; pjs.import("./main/increment.js"); increment(); console.log(x, y); // outputs 2 4 } exports.run = main; |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function main() { pjs.define("x", { type: "integer" }); pjs.define("y", { type: "integer" }); x = 1; y = 2; pjs.import("./main/increment.js", ["increment"]); increment(); console.log(x, y); // outputs 2 4 } exports.run = main; |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function main() { pjs.define("x", { type: "integer" }); pjs.define("y", { type: "integer" }); x = 1; y = 2; pjs.import("./main/*.js"); increment(); decrement(); decrement(); console.log(x, y); // outputs 0 0 } exports.run = main; |
...