DT-Europe Posted November 10, 2008 Posted November 10, 2008 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.
bradp Posted November 14, 2008 Posted November 14, 2008 [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.
ScottB Posted July 21, 2015 Posted July 21, 2015 [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.
steve.milici Posted July 21, 2015 Posted July 21, 2015 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.
ScottB Posted July 22, 2015 Posted July 22, 2015 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?
steve.milici Posted July 22, 2015 Posted July 22, 2015 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.
wehg Posted July 23, 2015 Posted July 23, 2015 [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.
ScottB Posted July 23, 2015 Posted July 23, 2015 [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.
steve.milici Posted July 23, 2015 Posted July 23, 2015 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)
Recommended Posts