OMRON Forums

# IF statement on multiple lines

## Recommended Posts

In a script PLC, how can we have a IF statement with conditions on multiple lines. As a very simple example for testing purpose, I tried following things without any success: IF(M2000 == 1 && M2100 == 1) IF(M2000 == 1 && M2100 == 1) IF((M2000 == 1 && M2100 == 1)) IF((M2000 == 1 && M2100 == 1)) When very very long conditions, we need multiple lines.

• Replies 8
• Created

#### Popular Days

[quote=DT-Europe] In a script PLC, how can we have a IF statement with conditions on multiple lines. As a very simple example for testing purpose, I tried following things without any success: IF(M2000 == 1 && M2100 == 1) IF(M2000 == 1 && M2100 == 1) IF((M2000 == 1 && M2100 == 1)) IF((M2000 == 1 && M2100 == 1)) When very very long conditions, we need multiple lines. [/quote] We will look into this and see what can be done. Look for more information in awhile.
##### Share on other sites

• 6 years later...
[quote='bradp' pid='80' dateline='1226700531'] [quote=DT-Europe] In a script PLC, how can we have a IF statement with conditions on multiple lines. As a very simple example for testing purpose, I tried following things without any success: IF(M2000 == 1 && M2100 == 1) IF(M2000 == 1 && M2100 == 1) IF((M2000 == 1 && M2100 == 1)) IF((M2000 == 1 && M2100 == 1)) When very very long conditions, we need multiple lines. [/quote] We will look into this and see what can be done. Look for more information in awhile. [/quote] Has this been fixed yet? Hard to believe in 2015, that you can't break complex conditional statements into multiple lines.
##### Share on other sites

This is not something to fix as this is the C-like standard for logic structures. It was our intent to make the script language in Power PMAC to be as much as possible C-like in its syntactical contructs.
##### Share on other sites

I'm not sure I understand, I thought standard C ignored whitespace. IF ((M1 == 0) && (M2==0)) is supposed to be identical to: IF ((M1 == 0) && (M2 == 0) ) and is identical to: IF ((M1 == 0) && (M2 == 0)) This is not the case in Power PMAC script (although it was in Turbo!). If this is never going to be "fixed", then is there at least some type of line continuation characters that we can use to break up extremely long lines?
##### Share on other sites

The C-like nature of Power PMAC script does not include the automatic line continuation of true C. This capability is not something that can easily be added to the script environment.
##### Share on other sites

[quote='ScottB' pid='8130' dateline='1437565026'] I'm not sure I understand, I thought standard C ignored whitespace. IF ((M1 == 0) && (M2==0)) is supposed to be identical to: IF ((M1 == 0) && (M2 == 0) ) and is identical to: IF ((M1 == 0) && (M2 == 0)) This is not the case in Power PMAC script (although it was in Turbo!). If this is never going to be "fixed", then is there at least some type of line continuation characters that we can use to break up extremely long lines? [/quote] I use the '\' on occasion in script for line continuation and it seems to work fine.
##### Share on other sites

[quote='wehg' pid='8149' dateline='1437663862'] I use the '\' on occasion in script for line continuation and it seems to work fine. [/quote] I wasn't aware of that, thanks. That helps break up long lines although the text editor in the IDE doesn't like it, it marks the lines with the red squiggly underline.
##### Share on other sites

The "\" character is not recognized as a line continuation signal by the script downloader. It is only used by the C compiler. There are probably many placements in a script file where it will not cause an error (treated as a CS on-line feedhold in the ASCII stream to PMAC), but the following will cause an error: if (P1==1 \ && P2==2)