• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Calling one script from another

Community Expert ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

InDesign has a nice mechanism for calling one script from another, so code can be made modular. What about FrameMaker ExtendScript? What methods are people using to call one script from another? Thanks for any suggestions.

Rick Quatro

TOPICS
Scripting

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

Hi Rick,

I write my scripts such that they always have the entire code in a function call, Basically, the only piece of code outside the main function call is calling that main function (so that I can test and debug each script separately). Then, when I use #include <scriptname.jsx> I can use that same script from another one. Normally, I write one overall script that installs the various commands in menus and contains the switch for the command function that calls each of the separate scripts, all of which are included via the #include. Save that overall script as binary and you do not need to drag all the scripts into the startup directory.

Kind regards from c-c-c-c-cold Netherlands

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 23, 2014 May 23, 2014

Copy link to clipboard

Copied

Hi Jang,

Can you further explain:

Save that overall script as binary and you do not need to drag all the scripts into the startup directory.

When I use #include <scriptname.jsx>, I get the following error:

Script Error :

Error Message      : File or folder does not exist

Script, Line#   : C:\path\to\script\overall_script.jsx,  1

This happens even when the two scripts are in the same folder.

Thanks in advance,

Trevor

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 23, 2014 May 23, 2014

Copy link to clipboard

Copied

Hi Trevor,

Note that ExtendScript is Javascript plus FM objects and methods, so you need to stick to Javascript syntax rules. The right way to include another script source is as follows:

#include "scriptname.jsx";

If this works when running the main script from the ESTK, you know it finds the included script. When you then Export the script to Binary (from the File menu of the ESTK), the binary will include the embedded script as well. After this you have a jsxbin file, which you can drop into one of the two available startup folders to make it fire automatically when FM starts. Or you can move it anywhere else and run it via the File > Script > Run command. The main idea here is that when compiling a script into binary format, all include references are resolved and the script contains the complete code. If you run the jsx, the script is interpreted and requires a correct relative reference to any included script.

I hope this clarifies things a little

Ciao

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 23, 2014 May 23, 2014

Copy link to clipboard

Copied

LATEST

Thanks for all your help! One last question, is it possible to include a script from a network server?

For example, something like

#include "\\network_server\path\to\scriptname.jsx";

Edit:

Just to be clear, what I would like to be able to do is modify the scripts called by overall_script.jsx without having to remake the binary file every time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines