LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Array Element problem with array of clusters

Interesting... That makes sense.  However, when I was coding the replace element function, it wouldn't un-break the wires unless i had the array of cluster typedef indicator wired to the shift register output.  not sure why i was havign this problem.  But followign your steps gave me teh correct behavior.  because of what i was experiencing, it made ti seem like the indicator typedef had to be wired to the shift register (input or output) for the replace array element function to know what it was populating.

 

I'm suprised that the function wouldn't let you take an empty array and populate a specific index of it and have anything from the zeroith index up to but not including that index default to zero.  LabView likes the variable length arrays... it just surprises me i can't do that.

 

Either way, the first call? function is probably the best solution.  Thanks for your help.

0 Kudos
Message 11 of 13
(774 Views)

PhilipJoeP wrote:

Either way, the first call? function is probably the best solution. 


You should really use a globally initialzed feedback node for the following reasons:

 

  • No need for "first call?"
  • No need for a loop at all!
  • Simply initialize with a diagram constant of your typedef control.
  • A globally initialized feedback node will get the initializer value on first call, and then never again during the same run.

 

Here's how the code could look like:

 

Message Edited by altenbach on 07-15-2009 02:24 PM
Message 12 of 13
(761 Views)

To PhilipJoeP: Note that what altenbach is showing you is the use of the Feeback Node which was introduced in LabVIEW 8.5. It can be used to replace shift registers (though I still prefer shift registers). Everything I was talking about was so you'd understand about the difference between types and values with shift registers. The construct shown by altenbach is the same as if you had a functional global with an "init" case (which could be triggered by a First Call?) that would initialize the shift register with data. The Feedback Node provides more compact code (though some, such as me, would argue that it's sometimes less readable). Also note that with altenbach's example if you did not have the array constant connected to the initializer terminal you'd have the same exact situation as what you were seeing with the uninitialized shift register.

 

Bottom line: the concept is the same, but the implementation is more compact with the Feedback Node.

Message 13 of 13
(745 Views)