Copy link to clipboard
Copied
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")
Copy link to clipboard
Copied
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()
Copy link to clipboard
Copied
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()
Copy link to clipboard
Copied
You can get to the enclosing folder with this snippet:
var x = File($.fileName);
var y = Folder(x.parent);
Copy link to clipboard
Copied
Similar ways also documented here:
https://gist.github.com/MarshySwamp/eb36460ae2813b6fc47e2d3fec48deb3