LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scope of re-entrant VI's shuft registers?

I'm creating a VI that will store the last n values of a waveform, and plot it on an XY graph, and in order to make it work properly, I need it to initialize the arrays on the first iteration. At present, it keeps an integer (via shift registers) around, and goes to the initialize case on the first time, when the register contains the default 0. However, the incremented value stays around even after the VI has run to completion: if I restart it, it doesn't work a second time. I can fix this with right-click -> Replace... with another copy of the same, so I'm pretty sure it's a matter of the register not going out of scope.

Is there any way to specify that it should, or am I stuck with "It either keeps the value 'til LabVIEW i
s closed, or it doesn't?"

~Dan
0 Kudos
Message 1 of 3
(2,552 Views)
You may add a boolean control to intialize/not initialize.
It has to be set from the calling vi
0 Kudos
Message 2 of 3
(2,552 Views)
Use the boolean output of the "first call?" node, it will do exactly what you need. It gives you a TRUE each time the code executes for the first time after the VI is run (found in Advanced..Synchronization, lower left corner). One of the lesser known gems.

From the online help:
"First Call? Indicates that a subVI or section of a block diagram is running for the first time. The First Call? function returns TRUE only the first time you call it, such as the first call after the Run button is pushed. You can place the First Call? function in multiple locations within a VI. The function returns TRUE the first time the section of the block diagram in which it is placed runs."
0 Kudos
Message 3 of 3
(2,552 Views)