Jump to content
OMRON Forums

IF statement on multiple lines


DT-Europe

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.
Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

[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.
Link to comment
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.
Link to comment
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?
Link to comment
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.
Link to comment
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.
Link to comment
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)
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...