LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Beginner - How can I loop an array and get all element data?

I have an array with more than 30 elements. This number can be variable.

I wanna try do simplify my code. So I am looking for a manner to loop the array, and get all the elements, one by one, and so wire them. Is it possible to do?

Thank you in advance.
0 Kudos
Message 1 of 8
(3,060 Views)
Here's a little example. It takes each item in an array of strings (which can be of variable size) and concatenates them together.
 
You'll love it: you don't even have to provide an upper bound to the FOR... loop.
 
0 Kudos
Message 2 of 8
(3,043 Views)
Auto-index a for-loop would be the immediate answer. However, usually the case with this kind of question is that the immediate answer isn't what the person is trying to ask, so the follow-up question would be: what are you trying to do with the values in the array? Also, to kdmcmullan, that technique is very inefficient in terms of memory management. To do something like that you should use the Array to Spreadsheet String function.

Message Edited by smercurio_fc on 05-09-2006 12:55 PM

Message 3 of 8
(3,042 Views)
I have an array with many elements... All of the elements were calculated but now, it is not important. So, I wanna get each one of these elements, all of them are numbers, and show them in a small window. I used for do it, something using the index array, but my screen are now full of wires, and it turned the code confuses.

Thank you in advance.
0 Kudos
Message 4 of 8
(3,031 Views)
Please post your VI. First make sure that some data is included. To do that run the VI with the data you want on the inputs and then Select Make Current Vaules Default. Save the VI. Attach it to your next post. The Attachment button is below the message box. If you want to review your message, do so before attaching your VI. Reviewing may cause the loss of the attaqchment.

Lynn
Message 5 of 8
(3,024 Views)

Not only is this method of string concatenation inefficient from a memory perspective, but it also requires more CPU cycles than other techniques. However, this was only ever intended to be an example on auto indexing. One where the advisee didn't have the added confusion of format string syntax!

Your point raises an interesting question, though: Can the array to spreadsheet function be used to concatenate strings without a seperator character? When I wire an emptry string constant to the delimiter input, I appear to get a space between each item.

 

0 Kudos
Message 6 of 8
(3,011 Views)
OK, if you were just showing it for an example, then I'll let you slide...Smiley Very Happy

As for your question, the answer is no, since the function automatically uses a tab if nothing is wired to the separator input. Wiring an empty string constant is the same as not wiring anything. To accomplish what you're suggesting you just need to feed the array directly to a concatenate string function like this:



You then get a concatenated string with no separators.

To the original poster: As suggested please post a small example of what you're trying to do. Is there something preventing you from using an array indicator on the front panel?

Message Edited by smercurio_fc on 05-10-2006 08:32 AM

Message 7 of 8
(2,996 Views)

I wonder how the internals of that work. It seems to be the case that if delimiter = "" then set delimiter = tab.

If I were doing it a s a VI, I'd have an input (delimiter) whose default content was a tab character. That way I could wire an empty string instead.

When I rule the world, software will all be better.

 

0 Kudos
Message 8 of 8
(2,989 Views)