06-13-2008 02:18 PM - edited 06-13-2008 02:19 PM
I take it back! There is no bug here! The assignment has a much higher operator precedance than the sequence operator so the 3 is assigned first and then the 14 is evaluated as a separate expression and it's result is discarded.
@rolfk wrote:
In fact there is a bug here since C syntax states that the sequence expression is evaluated from left to right and the last result is the result of the entire expression. LabVIEW does use the first result as result of the entire expression which is not according to the C syntax.
06-16-2008 07:07 AM
rolfk: In fact there is a bug here since C syntax states that the sequence expression is evaluated from left to right and the last result is the result of the entire expression. LabVIEW does use the first result as result of the entire expression which is not according to the C syntax.
Actually, geirove's LabVIEW snippet behaves just as it would in C, at least as far as the assignment goes. In C, the whole expression would be evaluated as 14, but a side effect would be to execute the assignment statement. X (or whatever the name of geirove's variable) would have the value 3 after the expression was evaluated, and that's what happens within the formula node. So as long as NI intended that comma operators in formula nodes should work that way, and documented the behavior properly, there's no bug.
Or do you mean, rolfk, that although LabVIEW is C-like in the way it does the assignment, it's not C-like in evaluating the expression because it incorrectly assigns the value of "x=3" (which is 3) to the expression "X=3,14"? That can't be determined from geirove's example--did you do some other test?
Regards,
--Marty
06-16-2008 07:08 AM
Oops, sorry, rolfk, I didn't see your "take back" message before I replied 8-).
--Marty