Ellié Computing Home Page
My Shopping Cart

Your shopping cart is empty

Display Cart

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Closed
sales@elliecomputing.com - Contact us


Running scripts at start-up

 

 

Ellié Computing Merge can run scripts at start-up in graphical user interface as well as from command line.

Scripts are run before the initial document is loaded and/or after the initial work is done (loading the initial comparison, and realizing export command if any) and after the GUI is displayed in GUI mode.

Syntax

ecmerge(.exe) --script="myscriptfile.js" --script-text="my_function('with', 'some', 'parameters')" --pdl-script="mypdlscriptfile.js" --pdl-script-text="my_pdl_function('with', 'some', 'parameters')"

Running such a command executes mypdlscriptfile.js then call my_pdl_function with the given arguments, then executes myscriptfile.js then call my_function with the given arguments.

The --pdl-?? options stands for Pre Document Loading, they are executed just before the document loads and before any merge or export operation happens. It is useful when you want your script to act on the document's options for example.

Time line

Here is what Ellié Computing Merge start-up executes with respect to the scripts:

  • parse the options
  • prepare initial document
  • execute "pdl-script" then "pdl-script-text" scripts
  • for quiet/sip
    • load document data
    • realize the merge/export action
  • start the gui if necessary
    • open the view on initial document
    • load macro scripts
  • execute "script" then "script-text" scripts

Notes

Note that executing a script containing only a function declaration will actually just declare it and make it available during that execution.

You will note the presence of the VFS.load_text method, coupled with the eval ( ) function of ECMAScript, you can actually load other scripts and execute them (which gives you a function similar to import of Java or #include in C/C++).

If you want to run from command line (whose default is to print a textual report of the comparison), you might want to use -Xnone to avoid such generation, though the comparison will still occur.

During startup, the initial_document as well as script_url variables are available in Application object. script_url is available during --script and --pdl-script only.

Platforms specificities with respect to [pdl-]script-text argument:

  • On Windows, the anti-slash character is the character used to separate path elements, but it is also the escapement character for ECMAScript, mixed with the fact that the double quote is used to delimit command line parameters, and there again conflicting somewhat with the usage of double quote for strings delimiters. You can circumvent such problems by using only simple quote as string delimiters in your [pdl-]script-text, have no spaces in it to call a function. In addition you can use the %PARAM:\=\\% notation to double anti-slash and therefore be able to call your script: e.g. --script-text=functioncall('%PARAM:\=\\%').
    NB: the replacement notation works only on recent Windows 2000 and more.
  • On Unix based OSes, slash is used for paths and quote are generally not necessary through the use anti-slash escaping which is interpreted at shell level. You should not need any specific effort, simply avoid putting the kind of quotes in your arguments which you use as string delimiter.

See Also