If Statement

Do you want a result of 1 if either of your first conditions is true and 2 if neither is true? If so, what you have should work, assuming the relative tag paths are correct.

Or do you want a result of 1 if the first condition is true and a result of 2 if the second condition is true? There are multiple ways to do this, depending on what result you want if both conditions are true or both are false. Here's an example using if that ignores the second condition if the first condition is true:

// Return 1 if first condition is true (regardless of second condition).
if({[.]…/CTR_VAC_ROLL_A_MODE}>0, 1,
	// Return 2 if first condition is false and second condition is true.
	if({[.]…/CTR_VAC_ROLL_B_MODE_TENSION}>0, 2,
		// Return zero if neither is true.
		0
	)
)

A simpler way to get the same result would use binEnum:

// Returns index of first true condition:
// 0 indicates both conditions false.
// 1 indicates first condition true, regardless of second condition.
// 2 indicates second condition true and first condition is false.
binEnum(({[.]…/CTR_VAC_ROLL_A_MODE}>0,{[.]…/CTR_VAC_ROLL_B_MODE_TENSION}>0)

Or use binEnc to capture all possible states:

// 0 (binary 00) indicates both conditions false.
// 1 (binary 01) indicates first condition true.
// 2 (binary 10) indicates second condition true.
// 3 (binary 11) indicates both conditions true.
binEnc(({[.]…/CTR_VAC_ROLL_A_MODE}>0,{[.]…/CTR_VAC_ROLL_B_MODE_TENSION}>0)
3 Likes