Private Variable Scope Rules And Clearing

Recommended Posts

My C++ background got the better of me today as I found a silly issue with my sequence code not working because I was using 'private' variables incorrectly with regards to scope.  The dynamic strength of DAQFactory allows private sequence variables, once executed, to be available until the sequence ends (in any block, not just for the local code block scope).


In my case, I had declared an uninitialized private variable in a while loop which conditionally appends arrays to the variable.  At the end of the loop, the arrays (if any) are processed.  I incorrectly assumed the private variable was reset empty with each loop interation.  I found that using arrayVar.ClearHistory(), even though the variable is not a channel, resolves my that a valid/preferred way to reset a variable?


Link to comment
Share on other sites


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