AnsweredAssumed Answered

If - Else - Else If structure confusion

Question asked by DanBrancaccio on Jun 25, 2020
Latest reply on Jun 26, 2020 by DanBrancaccio

Since there are no brackets or End If constructs in the PI Analysis statement windows i am having trouble understanding some code I been tasked with reviewing the code looks like this, there is minor indenting and Carriage returns. the question is initially do Carriage Returns act as delimiters in the code window or is this code

 

A similar question about readability. I am dealing with previously developed code, step one was very similar to what you have done to create a set of variables for the conditions tested then putting the logic into one statement like this

 

If Line2 = True Or Line4 = True Or Line6 = True Then OFF

Else

 If Line9 = True Then OFF

 Else If Line9 = True and Line11 = True Then ON

 Else

  If Line15 = True Then OFF

  Else If Line15 = True and Line17 = True Then ON

  Else If Line20 = True Then OFF

  Else If (Line20 = True) and (Line22 = True Or Line24 = True Or Line26 = True Or Line28 = True Or Line30 = True) Then ON

  Else If Line34 = True Then ON

  Else If Line34 = True and Line36 = True Then OFF

  Else If (Line34 = True and Line36 = True) And (Line38 or Line40 or Line42 or Line44 = True) Then ON

  Else OFF

 

the same as this?

 

If Line2 = True Or Line4 = True Or Line6 = True Then OFF

Else If Line9 = True Then OFF

Else If Line9 = True and Line11 = True Then ON

Else If Line15 = True Then OFF

Else If Line15 = True and Line17 = True Then ON

Else If Line20 = True Then OFF

Else If (Line20 = True) and (Line22 = True Or Line24 = True Or Line26 = True Or Line28 = True Or Line30 = True) Then ON

Else If Line34 = True Then ON

Else If Line34 = True and Line36 = True Then OFF

Else If (Line34 = True and Line36 = True) And (Line38 or Line40 or Line42 or Line44 = True) Then ON

Else OFF

Outcomes