The run-local funclet executes JavaScript code contained in a string or a disk file on the local machine in the current AutoShell session and returns the result. Code that is not contained in a surrounding function declaration is directly executed. Function declarations are processed so that the functions become available for later execution but are not called. While JavaScript file can be executed from the interactive command prompt by simply entering their pathname, run-local is the only way to execute external scripts from script files or to pass parameters to a script file when invoking it from the interactive command prompt.
The command has the following syntax:
run-local [script] [-file file] [-with args,...]
The return value depends on the specified script.
(Optional) Specifies a string containing the JavaScript code to execute. The funclet either executes a script from a string or from a file. Thus the script and file arguments are mutually exclusive. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parenthesis.
Default: ""
(Optional) Specifies the absolute or relative path to the script file to execute. The funclet either executes a script from a string or from a file. Thus the script and file arguments are mutually exclusive. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parenthesis.
Default: ""
Specifies a comma-separated list of actual arguments to pass to the script. The script code can access these arguments using the standard JavaScript arguments array.
Examples
Evaluate a simple expression:
run-local 1+2
Evaluate an expression from memory passing an argument:
run-local "arguments[0]*arguments[0]" -with 2
Write a script file and execute it:
s = "var i;" s +="for(i=0;i<arguments.length;i++)" s +="qout(arguments[i]);" s +="true;" memoWrit("script.js", s); run-local -file script.js -with 1, "abc", new Date()
Note: The script code is only directly executed when it is not contained in a function definition. The script does not return the result (in this case true) using the return statement, but by specifying it in the last expression executed.
Copyright © 2013 CA. All rights reserved. |
|