Jump to content
OMRON Forums

When do carriage returns matter?


steveneads

Recommended Posts

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

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

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

  • 3 weeks later...
Guest
This topic is now closed to further replies.

×
×
  • Create New...