Skip to main content
Participant
February 17, 2009
Question

javascript include?

  • February 17, 2009
  • 3 replies
  • 18391 views
Hi,

is there a way to include another script file into the current script (and then call a function from the other script)? e.g. to build a pure "library" file with lots of functions that can then be used by various other scripts.

Is that possible?
If tried things like include(path/to/file.jsx), but that didn't work.
Couldn't find much clue in the scripting docs...

Any idea?
This topic has been closed for replies.

3 replies

Participant
February 18, 2009
thank you Sir, exactly what I was looking for. Cheers!
Participant
February 17, 2009
Thanks a lot...very helpful!
Unfortunately, it seems that when I include one other JS file, I'm loosing the standard Photoshop objects (a scripts that was running fine before now doesn't). Do I have to add another line that declares that I want to include Photoshop's standard functions or something like that?
I'm a bit confused...
Known Participant
February 18, 2009
> Do I have to add another line that declares that I want to include Photoshop's standard functions or something like that?

If you are running it from within ESTK, make sure that you have
#target photoshop

as your first line.

-X
bluebeezle
Inspiring
September 18, 2018

What if I'm not running from ESTK? If I'm trying to build external libraries that I include in my scripts that are run from a panel, how do I make references to Photoshop's objects then?

Known Participant
February 17, 2009
>
> is there a way to include another script file into the current script (and then call a function from the other script)? e.g. to build a pure "library" file with lots of functions that can then be used by various other scripts.
>

//@include "xlib/stdlib.js"

or

#include "xlib/stdlib.js"


The first is needed for backwards compatibility with CS (which I have to worry
about) and maybe CS2.

This is documented in the JS Tools Guide in the ESTK chapter.

-X