LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

when to use local variables vs. cluster constants

i have this diagram.
is it right what i am doing?
i want to use bundle/unbundle to run my wires.
but in order to display the NEW VALUES ..i have to use local variables?
i was told never to use local variables so i dont know if what i am doing is right. can someone explain?
thanks in advance



Message Edited by krispiekream on 07-22-2008 07:18 PM
Best regards,
Krispiekream
0 Kudos
Message 1 of 11
(4,972 Views)

Whenever you want to display something, the value should be wired directly to the indicator.  That's what indicators do... they display things.

There are a few tricks to updating a display without using a local variable.  An easy one is to have a state machine that has an update all display case.  You put the new values to a shift register which is later read in the "display" case.   Same goes for clusters..

Local variables are nasty when the code grows... and code always grows.. So it is best to avoid them as much as possible.

R

Message 2 of 11
(4,962 Views)
Way too much code!
  • You index elements 0..10, so all you need is a single index array and you don't need to wire the indices.
  • If you would combine all your indicators into a cluster indicator, you don't need any of the local variables, just add an indicator to the cluster.
  • Some of your indicators have the wrong representation.
  • Why do you bundle to scan the strings then unbundle? Use array subsets on the original array, convert to the numbers, and index out.
  • Avoid right-to-left wires.
Message 3 of 11
(4,951 Views)

Whenever you want to display something, the value should be wired directly to the indicator.  That's what indicators do... they display things.

There are a few tricks to updating a display without using a local variable.  An easy one is to have a state machine that has an update all display case.  You put the new values to a shift register which is later read in the "display" case.   Same goes for clusters..

Local variables are nasty when the code grows... and code always grows.. So it is best to avoid them as much as possible.

R




Yeah, in this case, the values that I want to display in the front page is  CONTROLLER. i want the user to be able to change the value. thats why i can't use an indicator, so i have to replaced it with a local variables? I tried displaying AN INDICATOR for the local variable, but again, what i displayed in the front page will be the controller.

basically, my progroam take in a test sequence "text" file and display it in front page. if then the user wants to change the value, he can change it in the "text" file or change it in the front page after the program execute.

if its not much trouble, do you have little example of what you mean by "An easy one is to have a state machine that has an update all display case.  You put the new values to a shift register which is later read in the "display" case"

thanks


Best regards,
Krispiekream
0 Kudos
Message 4 of 11
(4,922 Views)


  • You index elements 0..10, so all you need is a single index array and you don't need to wire the indices.
  • If you would combine all your indicators into a cluster indicator, you don't need any of the local variables, just add an indicator to the cluster.
  • Why do you bundle to scan the strings then unbundle? Use array subsets on the original array, convert to the numbers, and index out.
  • Avoid right-to-left wires.
hi,i dont understand what you mean by the 1st action item. can you show me what you mean by not wiring up the indices and still get what i want? throughout my code it is wired that way. it could be wrong and it should be fix.

"Why do you bundle to scan the strings then unbundle?"? can you show me what you mean by Use array subsets on the original array, convert to the numbers, and index out.


also, in working with cluster, how do i avoid right-to-left wires?
i really hate doing that too but i dont know any alternatives.
thanks
Best regards,
Krispiekream
0 Kudos
Message 5 of 11
(4,919 Views)
Can you post your code?  I'll see if I can convert it to a state machine.
 
R
Message 6 of 11
(4,906 Views)
i would love to, but its huge and i dont know if it would be against company policy? sorry, i am new to everything.but really, i thank you for all your help though.


Message Edited by krispiekream on 07-24-2008 01:33 PM
Best regards,
Krispiekream
0 Kudos
Message 7 of 11
(4,896 Views)


krispiekream wrote:
hi,i dont understand what you mean by the 1st action item. can you show me what you mean by not wiring up the indices and still get what i want? throughout my code it is wired that way. it could be wrong and it should be fix.

There is nothing wrong with explicitly wiring all indices, but is is much more work and potentially can cause errors, e.g. if you accidentally cross some wires. THe more cluttered the code, the more difficult to verify correct wiring.
 
Here's an example picture. Compare with your code. 🙂
 

 


Message Edited by altenbach on 07-24-2008 11:40 AM
Message 8 of 11
(4,890 Views)
oh, i see, that is pretty nice
thanks~!
Best regards,
Krispiekream
0 Kudos
Message 9 of 11
(4,884 Views)


krispiekream wrote:
"Why do you bundle to scan the strings then unbundle?"? can you show me what you mean by Use array subsets on the original array, convert to the numbers, and index out.

Here's an example of what I meant (remember, you don't need to wire the indices at the end):
 


Message Edited by altenbach on 07-24-2008 11:52 AM
0 Kudos
Message 10 of 11
(4,877 Views)