Errors with including files when calling scripts with BridgeTalk

Explorer ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

I've been building a main Illustrator ScriptUI palette script that has some custom icon buttons on it that I can click to call other scripts. The scripts get called using BridgeTalk. Some of these scripts contain #include statements such as:

#include "jsx_modules.jsx"

...that contain frequently used functions so that I can easily call them from multiple scripts. This makes it so that I don't have to copy the same functions to multiple files which would be very hard to mantain.

 

This line of code as far as I can tell simply looks for other script files in the same directory as itself and just grabs their contents. This works quite well. But it causes a problem when I try to call scripts that have these #include lines by using BridgeTalk. My understanding is that using BridgeTalk to call scripts somehow executes the called scripts in a different directory entirely. I managed to find what I believe is that directory: C:\Users\USER\AppData\Local\Temp\esdebug

This means that since they are being executed in this other secluded directory, the #include line will cause a failure since it can't find the other function module scripts in this directory.

 

How do I go about solving this problem? Thanks.

 

If anyone needs I'll share the BridgeTalk code I'm using.

TOPICS
Scripting

Views

72

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , Apr 15, 2021 Apr 15, 2021
Yea, this happens, so I made me a function that reads the whole script text, finds all the lines with #include in them, takes those file paths, splices in the text from the file in the file path, then sends it through BridgeTalk. So you'll have to do this in your own approach, but it's simply done by splitting the whole text by /[\r\n]+/g and then you have an array of lines on which you can use array splicing functions. Also keep in mind that you can very easily splice a whole bunch of text line...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Yea, this happens, so I made me a function that reads the whole script text, finds all the lines with #include in them, takes those file paths, splices in the text from the file in the file path, then sends it through BridgeTalk. So you'll have to do this in your own approach, but it's simply done by splitting the whole text by /[\r\n]+/g and then you have an array of lines on which you can use array splicing functions. Also keep in mind that you can very easily splice a whole bunch of text lines into where one line was by replacing that array element and when you join the entire array at the end by array.join("\n") those multi-line elements will seamlessly cement themselves into the string.

Likes

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
Explorer ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

LATEST

Ah I don't know why I didn't think of that, thanks! Before this I actually went the not so smart route and just regex'd out the include lines thinking that would magically solve the problem. Of course it failed but at least I understand regex now lol. 

Likes

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