Dockable panel script laucnher

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
djbennyj
Posts: 11
Joined: April 7th, 2009, 5:47 am

Hey everyone.

I finished my script (the one i had problem with, in my previous topic); and i have 3 version of it, for 3 different task.

I'd like to launch my 3 script from a dockable panel.


I wrote the script for this, and it almoast works.
It create 3 button, but only the first launch 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.
Post Reply