Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Adobe .jsx scripts include other script files?

We're writing a bunch of .jsx scripts and in each I have to mock out some functions so I can use things like Array.map() and String.trim(), but I don't want to have to include that code at the top of every script.

Is there a way to "include" other .jsx scripts inside of a .jsx script file?

like image 910
rhodesjason Avatar asked Apr 01 '13 15:04

rhodesjason


People also ask

What is Adobe script?

A script is a series of commands that tells an application to perform a series of operations. You can use scripts in most Adobe applications to automate repetitive tasks, perform complex calculations, and even use some functionality not directly exposed through the graphical user interface.

How do I open a JSX file?

Because JSX files are plain text files, you can open them in any text editor, such as Microsoft Notepad (Windows) or Apple TextEdit (Mac). However, if you plan to edit a JSX file, you should open it in a source code editor, such as Microsoft Visual Studio (Windows) or Github Atom (cross-platform).


2 Answers

Or you can simply use #include and #includepath preprocessor directives at the top of your script. You can find a detailed description in Adobe's "JavaScript Tools Guide".

For example, if you want to include scripts/helper.jsx in a .jsx file:

#include "scripts/helpers.jsx"
// the rest of your code below ...
like image 193
Armin Avatar answered Oct 16 '22 21:10

Armin


Just leaving this here for anyone like me who is looking for this. In Adobe Illustrator CC 2015, I was unable to get #include to work, but @include did. So for example:

External File: foo.jsx

function alertTheWordNo(){
  alert('NO');
}

The Script File: bar.jsx

//@include 'foo.jsx';
alertTheWordNo();

Disclaimer: I cannot find any documentation of this but have tested it with Adobe Illustrator CC 2015 and it works.

Hope this helps someone. If anyone has any questions just ask!

like image 42
Ike10 Avatar answered Oct 16 '22 20:10

Ike10