03-05-2013 09:20 AM
I frequently need to trap a variable equal to zero or another number (-1). I have frequently connected the variable to the select input of a case structure set one state to the number I wish to trap using the default case for the normal code. I this more efficient less efficient or no difference to using an "equals zero vi then a Boolean to control a simple true/ false case structure?
03-05-2013 09:22 AM
I don't know. You could write some test code that does each one repeatedly in a loop and see which takes longer.
But why are you concerned?
03-05-2013 09:31 AM
To add the following:
What are possible future changes to the code? To be more specific: Does comparing the numeric value to a boolean state (equal, not equal, ...) restrict future changes?
Norbert
03-05-2013 10:09 AM
It depends on what is in the case structure. If it is a simple selection then the following snippet is faster, if you have subVIs in your case structure, then you will need a case structure. Note that the Slect function is faster than the case structure, but both a pretty fast. Only if you have a tight loop with millions of points will you start to see the difference.
Cheers,
mcduff
03-05-2013 10:19 AM - edited 03-05-2013 10:20 AM
In cases where all I care about is if something's true or not - for instance, a string match offset being -1 or not - I test for "T/F" instead of "-1 or other number" so I can use "select" instead of a case structure (provided it's something simple like choosing one value or another).
[edit]
oops, like mcduff
03-07-2013 04:24 AM
In this case the select toll is not appropriate as a decision is made whether or not to run some test software based on the value returned for a data and result index a value of -1, this case, means no data or index so don't run the test