....
> I have this situation: I am performing some data acquisition and I want to
> periodically write the data to disk in such a way like every hour or so,
> the data accumulated in the previous hour is written to a file with an
> extension that has the time and date.
>
> To do this, I would imagine a simple use of a local variable called
> Next_dump that is incremented another hour when the hour is up seems to be
> the way to go. However, LabView's funny thing with variables has puzzled
> me and after a lot of experimentation, I can't seem to make it increment
> past the first pass.
>
> My question specifically is: how do you get a local variable to be
> incremented if after a case structure has been false or true, a certain
> assignment is made to the variable?
>
I think there are really two questions here. First off, you probably want
to call a subVI each time through a loop that will either return the currently
opened file, or close the old one and open a new one depending on how much
time has elapsed. This can also be done in a case structure, but it makes
sense to build a subVI too.
Anyway, the file reference and a time reference, if needed, go into the code
which takes the current time, subtracts the reference, and determines if it
is time to open a new file. In one case it passes the file reference through.
In the other, it closes the current file, and either uses the current
time or
the old filename to create the new name, create the file, and wire out the
reference. This also assumes that the acquired points don't come in blocks
that need to be split into multiple files.
I'd use a shift register to pass the file reference and the time reference,
if needed. I wouldn't use a local variable in this case. You may be more
familiar with LV than I'm assuming, but one of the most common mistakes of
new users familiar with programming is to start making variables to store
things in. LV works much better if you resist the urge and instead use
wires and shift registers. You may want to browse through examples to get
the hang of it. It is partly a stylistic difference, but the overusage of
locals will affect performance and will introduce race conditions into your
program; so if you plan on using LV as a dataflow language, you might want
to limit your locals to parallel loop access and feedback controls in UI
diagrams.
The second question seems to be -- how to increment a local. The wire doesn't
represent a pointer; so make sure you read, increment, then write. Locals
can have any value written to them; so you may not need to read them because
you already have the value handy. Again, try to avoid reading and writing
things into variables the way you must in other languages, wires don't
evaporate, let them hold the data until you need it so that you can see
the dataflow of your algorithm.
Greg McKaskle