Facility Control

 View Only
  • 1.  Scripting question

    Posted 12-22-2014 19:41

    Hi there,

    I'm wondering if someone can help me with a scripting question? I have a lot of buttons in my custom panel, made up of choice constraint parameters using the toggle button widget. I'm working on a script that will ensure when one button is pressed, all the other ones will return to their default state. Here is what I've got:

    var otherbutton1 = 'Button.AwayPlayer';

    var otherbutton2 = 'Button.HomeGoal';

    var otherbutton3 = 'Button.HomePenalty';

    var otherbutton4 = 'Button.AwayGoal';

    var otherbutton5 = 'Button.AwayPenalty';

    if (this.getValue() == '0'){

    ogscript.debug('offline')

    }

    if (this.getValue() == '1'){

    for (i=1;i


  • 2.  RE: Scripting question

    Posted 12-22-2014 19:48

    Your code is telling DashBoard to set a parameters with OIDs "otherbutton1", "otherbutton2", ... but those are not your button OIDs.

    Note that you also shouldn't use the variable "i" without declaring it as a var in your loop.

    Here is a working way to do it using an array:

    `

    var buttons = new Array();

    buttons.push('Button.AwayPlayer');

    buttons.push('Button.HomeGoal');

    buttons.push('Button.HomePenalty');

    buttons.push('Button.AwayGoal');

    buttons.push('Button.AwayPenalty');

    if (this.getValue() == '0'){

    ogscript.debug('offline')

    }

    if (this.getValue() == '1'){

    for (var i = 0; i < buttons.length; i++) {

    ogscript.debug(buttons);

    params.setValue(buttons[i], 0, 0);}

    }

    `

    #DashBoard