I am using JXA for a workflow script for Alfred 2 and recently tried to run a script from another script. I need to pass text between scripts, so I decided to use parameters, but whenever I try to pass a string, number, array or something else that is not an object for it, it gives an error " Error on line 4: Error: An error occurred.". If I pass an object, the second script (the one that runs the first script) gets an empty object, not the one that was passed to it. The same thing happens when the first script is AppleScript, but if the second script is AppleScript, everything works fine. Passing arguments through osascriptfrom the command line also works . Is the API broken or is there something I'm doing wrong?
First script:
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.runScript(new Path("/path/to/second/script.scpt"), { withParameters: "Hello World!" });
Second script:
function run(args) {
return args;
}
Edit:
script , , , runScript script .
function run(args) {
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.displayDialog(args.toString());
return args;
}
2:
runScript , . , script, runScript, . , , .
Alfred 2
Alfred 2 ( , ..), , .
, . , script script. Bash, , Alfred 2 . script ( , , ), script, ( ).