cancel
Showing results for 
Search instead for 
Did you mean: 

if..else if..if

Former Member
0 Kudos

I am gettting a syntax error on the below code in bold. Can someone show me how to alleviate this error?

if (BLineRunning == 'YES' && BWeldEnd > 0);

/grid.setCellColorAsString(1,1, "red");/

grid.setCellBackgroundColorAsString(1,1,"red");

else if (BLineRunning == 'YES');

<b>if (BWeldEnd > BUSCenters || BCenter > BUSCenters || BHoldEnd > BUSCenters);</b>

grid.setCellColorAsString(1,2, "red");

else

grid.setCellColorAsString(1,2, "green");

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Not sure your sequence or indentation (if any), but if you have an "if" and an "else if" you also need a final "else".

So you could have this:


if (BLineRunning == 'YES' && BWeldEnd >0)
    grid.setCellBackgroundColorAsString(1,1,"red");
else (BLineRunning == 'YES')
    if (BWeldEnd > BUSCenters || BCenter > BUSCenters || BHoldEnd > BUSCenters)
        grid.setCellColorAsString(1,2,"red");
    else
        grid.setCellColorAsString(1,2,"green");

Also, don't use semicolons on the "if", "else if", or "else" lines.

Answers (1)

Answers (1)

Former Member
0 Kudos

Or you could do it like this:



if (BLineRunning == 'YES') {
	if (BWeldEnd > 0) {
		grid.setCellBackgroundColorAsString(1,1,"red");
	} else {
		if ((BWeldEnd > BUSCenters) || (BCenter > BUSCenters) || (BHoldEnd > BUSCenters)) {
			grid.setCellColorAsString(1,2,"red");
		} else {
			grid.setCellColorAsString(1,2,"green");
		}
	}
}