Recommended Posts

Actually, it can, you just have the syntax wrong. Two things:

1) Its Variable == OtherVariable + 1, doing a single = is assignment which isn't supported inside a function or statement (other than for()). Please see the blog entry about = vs ==

2) You need to specify the interval.

The correct format would be:

waitfor(Variable == othervariable + 1, 1)

which is pretty much identical to, but slightly less CPU intensive (and in some ways easier to read) than:

while (Variable != othervariable + 1)

Link to comment
Share on other sites

It could, but it would never be true. Well, essentially never. The variable would have to be changing elsewhere, and it would have to change into that state of being incremented by 1 in the microsecond between the time when DAQFactory retrieves it the first time and the second time.

What exactly are you trying to do?

Link to comment
Share on other sites

Thats what I was thinking, it would never be true. Tied my brain in a few knots earlier :)

I'm actually trying to get my export set to run each time my variable increments 1.

Link to comment
Share on other sites

Ok, well you probably want something like this:

private curvar = variable
while (1)
   waitfor(curvar != variable,1)
   curvar = variable

variable was a channel, or you were using history in the variable, you could use:

waitfor(variable[0] == variable[1] + 1,1)

but since you probably aren't, you need to use a temporary private variable to hold the previous value to compare to.

Note also that I didn't do variable+1, but instead did != (not equal). That way, if for some reason variable jumps by 2 instead of 1, the export set is still triggered.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.