Facility Control

 View Only
  • 1.  'Global' function in a panel

    Posted 10-28-2014 23:11
    Does anyone know if there is there a way to create a global ogscript function with code I can execute from any panel button (via ogscript) without having to redefine the entire function every time in that particular task?

    Basically I want to have several buttons, each with ogscript tasks, and each one would call that global function and pass a few different parameters, or maybe even run the function a few times with different parameters. It would make for a lot cleaner code and easier to maintain since my buttons are doing relatively the same thing with a few variables thrown in.

    Thanks!

    Joseph


  • 2.  RE: 'Global' function in a panel

    Posted 10-29-2014 14:06

    You can use a lookup table to do insert the same piece of code multiple times. If you look at some of the DashBoard U examples, you'll see this being put to use.

    Here is a minimal example:

             function saySomething(greeting, name)
    
    {
    
       ogscript.rename('NameLabel', greeting + ' ' + name + '!');
    
    }
    
    
          %const['GlobalScripts']['saySomething']%
    
    saySomething('Hello', params.getValue('params.name', 0));
       
    
          %const['GlobalScripts']['saySomething']%
    
    saySomething('Good-bye', params.getValue('params.name', 0));

    #DashBoard


  • 3.  RE: 'Global' function in a panel

    Posted 10-29-2014 14:33
    Ah, very good. Thanks James! I've modified this for my function and it works very well.

    #DashBoard