Copy link to clipboard
Copied
Hi community good afternoon,
just as the title says, does anyone know how to inlclude other scripts and libraries in the same script? For example I have a function named "C" in script "B" and I want to #Include "B" or something like that to call it from another file "A".
Thank you in advance.
3 Correct answers
Are you using VSCode? The simplest way is to use an "include" directive at the top of your script.
//@include 'path/to/script here.js'
This will have the effect of "running" the included script before running the script you are editing. Make sure the included script is terminated with a semicolon ;
- Mark
Hi @AntonioPacheco ,
You can use the #include "fileName" to access the function from another file.
Example:
1. Create file B.jsx and paste below code in that file.
function C(){
alert("Hi I am function C() from B.jsx file");
}
2. Create another file name as A.jsx and copy paste below.
#include "B.jsx";
function main(){
alert("I am main() function in script A.jsx and will call function C() from B.jsx");
C();
}
main();
Assuming, B.jsx and A.jsx files are in same folder.
just add the #include "full path" directive at top of your script
https://community.adobe.com/t5/illustrator-discussions/include-does-not-accept-spaces/m-p/4462966
Explore related tutorials & articles
Copy link to clipboard
Copied
Are you using VSCode? The simplest way is to use an "include" directive at the top of your script.
//@include 'path/to/script here.js'
This will have the effect of "running" the included script before running the script you are editing. Make sure the included script is terminated with a semicolon ;
- Mark
Copy link to clipboard
Copied
Yes I am using VS code! Thank you very much! Let me try this, thanks for all your help!
Copy link to clipboard
Copied
Hi @AntonioPacheco ,
You can use the #include "fileName" to access the function from another file.
Example:
1. Create file B.jsx and paste below code in that file.
function C(){
alert("Hi I am function C() from B.jsx file");
}
2. Create another file name as A.jsx and copy paste below.
#include "B.jsx";
function main(){
alert("I am main() function in script A.jsx and will call function C() from B.jsx");
C();
}
main();
Assuming, B.jsx and A.jsx files are in same folder.
Copy link to clipboard
Copied
Thank you let me give it a try!
Copy link to clipboard
Copied
just add the #include "full path" directive at top of your script
https://community.adobe.com/t5/illustrator-discussions/include-does-not-accept-spaces/m-p/4462966
Copy link to clipboard
Copied
I did not know about this thread, thank you! It's usefull

