Checks if a variable or expression has changed its value since the previous analysis.
Syntax |
i32 diff (var) |
||||||
---|---|---|---|---|---|---|---|
var |
Parameter to be checked. Must be of type numeric (i8, i16, i32, u8, u16, u32, float, real) or boolean (logical expression) |
||||||
Result |
Returns:
|
||||||
Validity |
Rule, Task |
||||||
Note |
The first time it is executed, the function returns FALSE and stores the current state of the condition. In case diff() is used in a user R3 function, it should be avoided that the parameters of the function itself are involved in the "condition" expression. The result would not be as hoped because of the overlap in memory of the state of multiple variables |
Each diff() instruction has its own memory of the "condition" state.
The evaluation of the front is done between the current state of the condition and the memory related to the single function call.
For example, if we have at step 1000 if(diff(inp(1 ))) and at step 1100 if(diff(inp(1))), though they refer to the same condition, the evaluations are done separately, each according to the stored state, by executing step 1000 and then step 1100.
Example of use:
|