steveneads Posted July 12, 2016 Share Posted July 12, 2016 I've just been debugging a PLC that wasn't working as I expected. I had the lines: brEndTime = Sys.Time + 0.5; while (Sys.Time < brEndTime) {brState = 631;} //wait for 0.5 sec This code did not appear to wait in the while loop at all. Adding carriage returns as below fixed the problem: brEndTime = Sys.Time + 0.5; while (Sys.Time < brEndTime) { brState = 631; } Is this to be expected? Thanks Steve Link to comment Share on other sites More sharing options...
steve.milici Posted July 12, 2016 Share Posted July 12, 2016 Technically this should work. If the IDE is somehow mis-parsing the script you might see it in the results of a list PLC in the terminal window. Link to comment Share on other sites More sharing options...
steve.milici Posted July 12, 2016 Share Posted July 12, 2016 As to the carriage return question – you cannot have a carriage return inside syntactically atomic statements, as in the following: 1. A condition within parenthesis, (Sys.Time < brEndTime) and its statement (if, while ...) 2. An assignment statement, brState = 631 3. An identifier or keyword, brState or Sys.Time - not even spaces allowed here. The curly braces are each syntactically atomic so they can be on separate lines or not. Your case above may be confusing the parser in some way. Link to comment Share on other sites More sharing options...
steveneads Posted July 13, 2016 Author Share Posted July 13, 2016 Hi Steve I tried your suggestion, but as far as I could see, the listing looks correct. However, the two versions of code don't work in the same way. Seems a little concerning to me! Steve Link to comment Share on other sites More sharing options...
steve.milici Posted July 13, 2016 Share Posted July 13, 2016 I tried several arrangements of code (and yours exactly) and could not get your results. What is your IDE and firmware versions? What is the hardware platform? Link to comment Share on other sites More sharing options...
finchyt02 Posted July 13, 2016 Share Posted July 13, 2016 System Info when we encountered the issue CPU:465 f.w. version: 2.1.1.3 IDE version: 2.1.0.107 (by right clicking on the "Power PMAC Suite Application.exe) Tom Finch Link to comment Share on other sites More sharing options...
finchyt02 Posted July 14, 2016 Share Posted July 14, 2016 Hi Steve, I ran the "list SubProg" command on my system above: Here is the broken code: L2=Sys.Time+0.5 while(Sys.Time Here is the working code: L2=Sys.Time+0.5 while(Sys.Time { P9087=631 } The IDE doesn't seem to have missed any of the brackets for the broken code Tom Link to comment Share on other sites More sharing options...
steve.milici Posted July 14, 2016 Share Posted July 14, 2016 Contact me by email - I would like to give you some procedures to try: smilici@deltatau.com Link to comment Share on other sites More sharing options...
steve.milici Posted August 4, 2016 Share Posted August 4, 2016 We were not able to reproduce this issue in any form. My best guess to the cause would be the introduction of non displayed control characters via cut and paste. Link to comment Share on other sites More sharing options...
finchyt02 Posted August 5, 2016 Share Posted August 5, 2016 You mean like the control characters you'd see if you did: CTRL+R, CTRL+W. or Edit -> Advanced -> View White Space Link to comment Share on other sites More sharing options...
steve.milici Posted August 5, 2016 Share Posted August 5, 2016 Also characters above ASCII 127. Link to comment Share on other sites More sharing options...
Recommended Posts