Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

start script from another script

Community Beginner ,
Apr 16, 2025 Apr 16, 2025

Hello, everybody!

 

I have 2 scripts: first.jsx & second.jsx

 

In UI in first.jsx I have a Button. If I press to this button, I need to start second.jsx.

How can I start second.jsx? Both scripts are in same folder.

 

first.jsx:

var dlg = new Window("dialog", "Try to start second.jsx");
dlg.testButton = dlg.add("Button", undefined, "start second.jsx");

dlg.testButton.onClick = function(){
    //missing code
}

dlg.show()

 

second.jsx:

alert("second.jsx successfully started")
TOPICS
Actions and scripting
87
Translate
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
Adobe
Community Beginner ,
Apr 16, 2025 Apr 16, 2025

Now, I try this code. It work.

 

var dlg = new Window("dialog", "Try to start second.jsx");
dlg.testButton = dlg.add("Button", undefined, "start second.jsx");

dlg.testButton.onClick = function(){
    var curScr = $.fileName;
    var path = curScr.slice(0, curScr.lastIndexOf("/")+1);
    $.evalFile(path + "second.jsx")
}

dlg.show()
Translate
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
Community Beginner ,
Apr 16, 2025 Apr 16, 2025

I think, this code is correct. In this code we don't check existence of "second.jsx":

var dlg = new Window("dialog", "Try to start second.jsx");
dlg.testButton = dlg.add("Button", undefined, "start second.jsx");

dlg.testButton.onClick = function(){
    var curScr = $.fileName;
    var path = File(curScr).parent;
    $.evalFile(path + "/" + "second.jsx")
}

dlg.show()

 

Translate
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
Enthusiast ,
Apr 16, 2025 Apr 16, 2025

You can get to the enclosing folder with this snippet:

var x = File($.fileName);
var y = Folder(x.parent);
Translate
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
Community Expert ,
Apr 16, 2025 Apr 16, 2025
LATEST
Translate
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