Page 1 of 1
function defined in another file
Posted: January 17th, 2006, 12:14 pm
by pirelouit
Maybe it is a stupid question, but how do you make a call to a function defined in another file? I imagine you must specify a relative path, but I couldn't find anything about it in the adobe documentation.
Thanks
Calling function in another file
Posted: January 17th, 2006, 12:22 pm
by redefinery
In AE 6.5 or later, you'll need to open the file, eval() its contents, then close the file, as in:
Code: Select all
var myCodeFile = new File("codeFile.jsx");
myCodeFile.open("r");
eval( myCodeFile.read() );
myCodeFile.close();
See the render_and_email.jsx script for examples.
In AE 7, you can use the new #include directive, as in:
Jeff
Posted: January 17th, 2006, 12:59 pm
by pirelouit
Thank you, I realized now I was simply not looking in the right place in the documentation. I appreciate the quick feedback.
Posted: June 18th, 2007, 1:12 pm
by Tigerfog
Hi.
I have tried to use the codes that you have given me.
However, when I run my script, it says "Expected: (" at the line where "#include" is.
Then, I tried again with parentheses around the URI path of my jsx file. This time, the message I get was that the file or folder does not exist, even though I correctly input the absolute path of my script.
Is there another way to script a reference to an external file?
Posted: June 22nd, 2007, 8:30 am
by Tigerfog
Sir pirelouit found the solution for me!
My script with the "#include" code worked on his MAC, but not my poor, poor PC.

Here is what he gave me and this time, my script ran perfectly on my PC:
// @include "(path)";