I have a "Success!" indicator that I want to set TRUE if the external library call to the DLL was successful. I also want to set it FALSE when I run the VI, so that I'm sure that it's TRUE because the call succeeded, and not because the state is left over from the last run.
So I went to Create Invoke Node: Initialize to Default and placed it on the VI. When I run the VI, the indicator stays FALSE, even though the library call successfully returns values from the DLL (which also proves that the call succeeded). It's as if the Initialize happens _after_ the compare returns true, instead of before the compare runs.
I turned on Highlight Execution to debug it, and now it works properly.
. This is 100% repeatable. If I turn off Highlight Execution if indicator stays FALSE after a successful run; if I turn on HE, it turns to TRUE after a successful run.
I thought the whole point of the Invoke Node: Initialize to Default was that it would occur first, no? Or is my understanding incorrect?
I think I found a workaround, which is to wire the Error Out from the Initialize to the Error In on the library call, which I think forces Init to run first. Is my interpretation correct? I can't prove this, because debugging it also avoids the problem. But this also is 100% repeatable.
Without that wire my indicator is always incorrectly FALSE after a run, and with that wire my indicator is always correctly TRUE after a run (unless I disconnect the hardware to force a failure, e.g. then it's correctly FALSE after a run). With that wire, if I run the VI again and again, I can see it briefly flash to FALSE before turning TRUE, e.g. the intended behavior. But why do I need this workaround, and/or why does this behavior change when HE is on? Thanks!
![InitToDefaultHappensLate.png InitToDefaultHappensLate.png]()