DashBoard control of Carbonite

Having problem with this script.

var oldValue = ogscript.getObject(‘0x10CD-Old’);
var xpt = params.getValue(0x10CD,0);

if (oldValue == xpt)
return;
ogscript.putObject(‘0x10CD-Old’, xpt);

if (xpt == 1005)
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 01’); rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 01’);
if (xpt == 1007)
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 02’); rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 02’);
if (xpt == 0)
ogscript.reveal(‘CHANGE-1’);
This is a key buss in the switcher. It will do the if statements correctly but then it will always execute the last command listed. rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 02’); no matter what is selected.

If you don’t use curly braces, only the line immediately following the “if” (where the line ends at the first semicolon) is actually part of the if statement.

What you wrote is equivalent to this:

var oldValue = ogscript.getObject(‘0x10CD-Old’);
var xpt = params.getValue(0x10CD,0);

if (oldValue == xpt)
return;
ogscript.putObject(‘0x10CD-Old’, xpt);

if (xpt == 1005)
{
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 01’);
}
rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 01’);

if (xpt == 1007)
{
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 02’);
}
rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 02’);

if (xpt == 0)
{
ogscript.reveal(‘CHANGE-1’);
}
Where what you really want is more like this:

var oldValue = ogscript.getObject(‘0x10CD-Old’);
var xpt = params.getValue(0x10CD,0);

if (oldValue == xpt)
return;
ogscript.putObject(‘0x10CD-Old’, xpt);

if (xpt == 1005)
{
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 01’);
rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 01’);
}

if (xpt == 1007)
{
rosstalk.sendMessage(‘172.16.0.102’, 7788, ‘MEM 02’);
rosstalk.sendMessage(‘172.16.0.103’, 7788, ‘MEM 02’);
}

if (xpt == 0)
{
ogscript.reveal(‘CHANGE-1’);
}

#DashBoard