Bmarsh wrote:
> I'd like to retain the value between calls to a subVI, as can be done
> using a static function scoped variable in C. The textbook example of
> how this is used would be a variable in the function that is a state
> machine, and knows what state it was in last time it was executed. A
> simpler example would be just keeping count of how many times the
> function has been called.
>
> I suppose I could use a global or I could pass values in and out of
> the subVI, but I'd like to keep the variable known only in the scope
> of the subVI if at all possible. For example, the outside world has
> no business knowing (or god forbid) changing what the state
> information of this function is.
There is no need to do something "conceptual" or spec
ific to have this
static variable. You already have this in any control or indicator in
your sub-vi while it is in memory. Control/indicator value will remain
in sub-vi data space between calls. Don't forget about make your sub-vi
non-reentrant or keep track of sub-vi data space copies.
If you want to read/write this value from another vi, consider it global
or I'd prefer to suggest using functional global(uninitialized shift
register in 1 iteration while loop). Think of it as about 1 value data
repository.
LabVIEW CIN reference manual is a good place to look at, as well as
LabVIEW course kits, describing LabVIEW memory issues in details.
To simplify: create empty sub-vi with control and indicator connected to
each other and call it wiring indicator in caller vi. Keep sub-vi front
panel open and change control in sub-vi manually. You see what happens.
--
Sergey Krasnishov
____________________________________
Automated Control Systems
National Instruments Alliance Member
Mos
cow, Russia
sergey_acs@levsha.ru
http://acs.levsha.ru