I finished my script (the one i had problem with, in my previous topic); and i have 3 versions of it, for 3 differents tasks.
I'd like to launch my 3 script from a dockable panel.
I wrote the script for this (based on a script i found here) , and it almoast works.
It creates 3 buttons, but only the first launches its scripts. The 2 others are inefectives...
Code: Select all
{
function onScriptButtonClick()
{
var scriptFile = new File(this.currentDirectory+this.scriptFileName);
scriptFile.open();
eval(scriptFile.read());
scriptFile.close();
}
function addScriptButton(palette, buttonRect, buttonLabel, buttonCurrentDirectory, buttonScriptName)
{
var newButton = palette.add("button", buttonRect, buttonLabel);
newButton.scriptFileName = buttonScriptName;
newButton.currentDirectory = buttonCurrentDirectory;
newButton.onClick = onScriptButtonClick;
return newButton;
}
function createUI(thisObj)
{
var myPanel = ( thisObj instanceof Panel) ? thisObj : new Window("palette", "Lancement méteo", undefined, {resizeable:true});
var BTmidi = addScriptButton(myPanel,[0,0,130,20], "Meteo du midi", "/Medias/benji/scripts/", "meteo_semaine_midi.jsx");
var BTsoir = addScriptButton(myPanel,[0,30,130,20], "Meteo du soir", "/Medias/benji/scripts/", "meteo_semaine_soir.jsx");
//var BTWe = addScriptButton(myPanel,[0,60,130,20], "Meteo du week end", "/Medias/benji/scripts/", "meteo_week_end.jsx");
//You can add how many buttons you want
return myPanel;
}
var YourPanel = createUI(this);
if (YourPanel instanceof Window) YourPanel.show();
}
Here is the code.
I hope somone will spot my mistake

Regards,
ben.