Douglas,
This is not necessarily an improvement. Calling the VI's dynamically can be
difficult if the VI's take a lot of inputs, or when all the VI's need
different inputs.
But, I agree, the possibilities are numerous. The array of strings (or
enumerated type def, if you like) can be used to get the next state in a
state machine.
I used this method (with strings) in an application using a tree. The button
names change when a different tree item is chosen. The "read buttons" state
jumps to the next state (the button name that is pressed), using an array
that has the names of the current button names. (The names of the buttons
can be changed from the ini file. The ini file also cahnges the tip and
description of the buttons. The data in the tree is filled from a database,
actually four databases.)
All of these methods can be easily enhanced to handle menu items and events.
I'm not a big fan of dynamically calling VI's because it's (slightly) more
difficult to read. Not for me, but for my colleagues that may have to
service the code when I am not available.
Regards,
Wiebe.
"Douglas De Clue"
wrote in message
news:6f0395b7.0207231319.6a29014e@posting.google.com...
> An improvement on the array of boolean buttons with search 1D array
> and a increment one and case structure architecture would be to use
> the index value from the search 1D array to select from an array of
> strings containing the names of VI's to be dynamically launched. In
> fact the names of the VI's to be dynamically launched and the button
> labels associated with those VI's could even be kept in an SQL
> database (like Microsoft Access) so that you could change how the
> program works merely by changing the database entries.
>
> This way you wouldn't need to revalidate your user interface just
> because you added new cases or removed them, or changed the
> functionality of individual cases. You would only need to validate
> the code that gets launched dynamically if you change or add it.
>
> Douglas De Clue
> LabVIEW developer
> ddeclue@bellsouth.net
>
>
> "Wiebe@AIR" wrote in message
news:...
> > Hi,
> >
> > Put the buttons in an array. Use the Search 1D Array function to find
the
> > first TRUE value. Now you have an index. (If the buttons are in a
bundle,
> > use Bundle to Array function. This might be a good idea, it can be more
> > practical.)
> >
> > Now you have three options:
> >
> > 1) Put Parameter N in an array, and use the index from previous code as
an
> > index. (You might want to add 1 to the index, if no button is pressed,
> > previous code retuns -1. Plus 1, it will give 0, make the first index
the
> > default value.)
> >
> > 2) Put functionality you want to execute in a case structure. If you
reuse
> > functionality, make the case execute in all cases that apply (e.g. put
1,2,3
> > in the case if you want to execute them in case 1, 2 or 3. Use 1..3 as a
> > shortcut.) Be carefull with the default case.
> >
> > 3) Combine 1) and 2). This can be done in unlimited ways.
> >
> > Regards,
> >
> > Wiebe.
> >
> >
> > "none" wrote in message
> > news:ahj2la$8gu$1@news.net.uni-c.dk...
> > > Hello
> > >
> > > I am writing an program in LabView 6i where I have 20 buttons that
needs
> > to
> > > be tested in every program loop. If button n is pressed the program
runs
> > an
> > > subvi with the parameter n. Right now I am doing this with an
sequence
> > (20
> > > long) and in frame n I test button n with an case and if true run the
> > subvi
> > > with n.
> > > Please tell how to do this without repeating the same code 20 times.
> > >
> > >
> > > / Peter
> > >
> > >