Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E157 - Bare integer combined with a duration

Adding an integer to a TIME or subtracting one from it reads the integer as milliseconds, because that is what a TIME holds. For LTIME the integer is read as nanoseconds. The operation compiles, but the unit is only implied.

Code example:

PROGRAM mainProg
VAR
    cycle : TIME := T#10ms;
END_VAR
    cycle := cycle + 5;
END_PROGRAM

To silence the warning, give the number its unit:

    cycle := cycle + T#5ms;