Programmer's Guide > Using the AOM > Using JavaScript to Access the AOM > JavaScript and ACL
  
JavaScript and ACL
JavaScript expressions or scripts can be called from ACL with one of the following ACL primitives:
javascript — Function that evaluates a JavaScript expression and returns the result as a string.
js_source — Function that reads and executes a file containing a JavaScript program.
js — Command that evaluates a JavaScript expression and displays the result.
source — Command that interprets files ending in .js as JavaScript programs to be executed when set javascriptinterpreter is set to rhino.
The flow of control in the JavaScript interface usually starts with the execution of one of these ACL functions or commands, with the exception of customization files ending in .js. Arbortext Editor and the Arbortext PE sub-process automatically load and execute JavaScript programs from the doctype.js, instance.js, and document.js files following the same rules as doctype.acl, instance.acl, and docname.acl files.
The JavaScript interpreter starts the first time Arbortext Editor or the Arbortext PE sub-process executes one of these ACL functions or commands or reads a .js customization file. Arbortext Editor and the Arbortext PE sub-process will also start the Java Virtual Machine, if necessary. You may also specify the -jvm and -js startup command options to start Java and JavaScript, respectively, when Arbortext Editor is opened.
Unlike the Java interface, only string arguments are passed from ACL to JavaScript. So any ACL argument value passed to js_source is converted to a string. ACL arrays must be converted to some form of delimited string (for example, as an array literal) or passed element by element to JavaScript expressions. Refer to Passing Arrays Between JavaScript and ACL for more details.
JavaScript objects may not be returned directly to ACL. If the result of a JavaScript expression passed to javascript is an object, the toString method is invoked on the object and that value is returned by javascript.