LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically change case structure range

Solved!
Go to solution

I think I already know the answer to this, but I'm going to ask anyway. In the attached image, is it possible to programmatically change the range of numbers the case uses?

 

Tay

0 Kudos
Message 1 of 7
(5,645 Views)

There is probably some method using scripting to be able to do this.  But even if it is available, is it worth the trouble?

 

Why do want to this?

 

I would suggest turning each case into a particular enum value.  Then use other code ahead of it to convert your value to the particular enum value based on comparison conditions which would be much easier to change programmatically.

Message 2 of 7
(5,641 Views)
If you have scripting, the FrameNames property of a case selector will do the trick.  You should probably read it first, change the name in the array, then write it back.
0 Kudos
Message 3 of 7
(5,627 Views)

Well, I had this code in place and then the requirement came down to be able to easily change the range of values each case handles without recoding. I was idly wondering if there was some easy magic trick I didn't know about to change the range of numbers each case handles. I guess not. So I'll rewrite it. 

 

Thanks.

 

Tay

0 Kudos
Message 4 of 7
(5,626 Views)

DFGray,

 

I have the Scripting unit installed. I can't seem to find the Property of a case selector. I right-click on the case and there are no properties to set. If I drop a property node on the vi, a random search doesn't show the framenames property.

 

 

Tay

0 Kudos
Message 5 of 7
(5,599 Views)
Solution
Accepted by topic author slipstick

I would probably solve the problem programmatically, e.g. as follows.

 

Start with Ravens idea above, and use an array of range boundaries, e.g. as described here

 

 

 

0 Kudos
Message 6 of 7
(5,594 Views)

To use a property node on a case selector, you need to have a reference to it.  There are several ways to open the reference, depending on where the object you want to reference is located.

  1. EASY - If the case selector is not inside another structure and has a unique name, use Open VI Object Reference with the name of the case selector as the input.  The owner is the block diagram reference and the object class is a case selector.
  2. FAIRLY EASY - If the case selector is inside another structure or structures and all structures and the case selector have names unique to their diagrams, open the structures from outside to inside as in case 1.  After you open the structure reference, get a reference to the appropriate diagram and repeat until you get to the final case selector.
  3. HARDER - Case selector has a unique name, but is buried in a container which does not.  Use the Traverse method to find all case selectors, then use the Label property of each to find the right one.
  4. HARDEST - Case selector does not have a unique name.  Use the Traverse method to find all case selectors, then find the one you want by the frame labels.
The take-home message from this is that your life is much easier if you give your containers unique names.
0 Kudos
Message 7 of 7
(5,559 Views)