Skip to main content
dublove
Legend
April 1, 2026
Question

Can a function in a subfile call a function in the main file?

  • April 1, 2026
  • 0 replies
  • 9 views

Due to repeated code and cross-references, I want to use a separate file, but I can’t completely separate the code.For example, I have a main file,

A.jsx (this name may be renamed frequently):

//@include ‘B.jsx’;
        var doc = app.activeDocument;
        var item = doc.selection[0]; 
        var items = doc.selection; 
b();

function a{

...
}

Subfile B.jsx (this name is fixed):

//@include ‘../pub/A.jsx’;
        var doc = app.activeDocument;
        var item = doc.selection[0]; 
        var items = doc.selection; 
function b() {

...
    a(); // Here, I need to call `a()` from the main file A.jsx

...
}


Now here’s the problem:

The path between A.jsx and B.jsx is a relative path, and this will not change.

However, A.jsx might be renamed frequently in the future.
Is there a way to determine its name in reverse?

Thank you.