07-26-2013 04:28 PM
Under Other functions PtbyPt, there are increment Ptby Pt and decrement PtbyPt. Under Execution in VI properties, reentrancy is set to Preallocated clone reentrant execution. Does that mean I can use that VI to count multiple things? If that VI can be use for multiple counters, how does LabVIEw keep track?
Solved! Go to Solution.
07-26-2013 05:08 PM
Preallocated Clones - each call has its own memory space. So you can call this VI from multiple places and each place you call it will have its own memory. So yes, you can keep track of multiple counts.
07-26-2013 11:50 PM
Does does LabVIEW keep track of multiple counters if I use that VI as my counter? For example, if I use that VI to act as 3 counters. One counter counts up to 100, then second one counts up to 200, and the third one counts up to 300. They are all increment at different places of the code. How woudl LabVIEW knows which on is which? By looking at the code, a real person may not even be able to tell.
07-28-2013 06:39 AM
There will be an instance for each call to that VI. Each instance (called a clone) will keep its own counter. To LabVIEW, they each act like totally different subVIs.
The LabVIEW Field Journal had a good series on maintaining state. I recommend reading the 5 part blog series. Part 1 can be found here:http://labviewjournal.com/2012/02/maintaining-state-1/
07-30-2013 10:23 AM
See attached example. I dont' see how it keep track of which counter is which.
07-30-2013 10:42 AM
Each call has its own data set. So the VI calls in the init case are different from those in Counter 1 or Counter 2 cases. So you really have 6 counters going in your VI. Need proof? Put a FOR looop around your VI and have it iterate twice. You will notice that you will get 10 for counter 1 in the counter 1 case. It wasn't reset like you wanted to happen in the init case because those calls in the init case are different instances than those in the Counter 1 case.
07-31-2013 11:13 AM
Oh, that makes sense. Thanks!