LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string control, appending lines

Hello All;

First I want to say I'm new to LabView. I am a currently a Java Software Developer. I want to learn labview because it looks really cool. Once I'm up to speed, I can imagine the productivity with it. I know I will be real productive with labview.

My question is concerning the String control in the front panel.

I'm am reading a csv file and all I want to do is display the contents in a String control. I have a loop that iterates over the read file line by line. I don't know how to call the String's control methods to append a line of text instead of replacing it.

Again my question is,
how do I insert new lines instead of replacing them?

Here is a picture.
0 Kudos
Message 1 of 8
(5,208 Views)
I ended up using a list box. But I save the interim data in an array. I did not see a way to set each line in a list box one at a time.

How do you set the list box items one at a time?

Here is a second attempt attachment.
0 Kudos
Message 2 of 8
(5,196 Views)
If you want to read a csv file, I suggest you use the read from spreadsheet file VI. For some reason it doesn't support strings so you'll have to go into its code (by double clicking it), where you'll find instructions for how to modify it. Just make sure to save the VI elsewhere. This way, you'll get an array of strings which is a much more convenient structure to work with. Anyway, it looks like if you want to replace just one element in your listbox, you'll have to have an ItemNames property read and use the array coming out of that, in conjunction with the array functions (replace subset, insert into) to recreate the array and wire that into a write property node.
To append lines of text in the string, you need to use a shift register, and to wire the shift register output, a CR and your new line into a concatenate string VI, the output of which goes back into the shift register for the next loop. And you're right - LabVIEW is cool.

___________________
Try to take over the world!
0 Kudos
Message 3 of 8
(5,176 Views)
If you want set only one item you have change this item in array and insert all array again to ItemNames
0 Kudos
Message 4 of 8
(5,176 Views)
It does not seem that I can insert one line at a time at the end in the list box because it will replace the current items.

I don't know if using an array to hold my data is a good idea.

When I set the data array of strings into the listbox, does the listbox makes a copy of my data?

If it does, now I have two copies of my data the array and the data in the listbox.

I don't think I want two copies.

What I was thinking of doing was to iterate over the file line by line and then append/insert that line in the list box control or the string control. I'm not interested in storing the data in the array.
0 Kudos
Message 5 of 8
(5,147 Views)
Whenever you write data to a listbox, you have to write it as an array and the listbox does not keep a copy of whatever it held before. The new array completely overwrites the old array so there is no copies being made. Look at the attached picture. The top method will take the existing items and add one to the end. The bottom method will take the existing items and insert a new one in a position you would specify.
0 Kudos
Message 6 of 8
(5,142 Views)
Great.

Thanks for the vi info. It helped alot. I'm still learning alot. I'm discovering alot of useful features. Almost everything is a click away.

Because I wanted to monitor the memory, I created a "write vi" that writes one line at a time to a file. It flushes every 1000 lines. I created one big text file (close to 1G) for this memory test.

I used the Windows Task Manager. If the memory spiked after I set the array of strings into the list box, then I would know LabView copies my data by value. The memory stayed the same even after the loop completed. Which means labview listbox takes the array by reference. Or maybe my original data is lost because it is not stored anywhere?

I then set up an event to delete half the contents of the array. It seems the delete function makes a copy of the array and can give you the deleted portion or the left portion.

Anyways this seems to indicate labview passes references in some cases and copies data in others. I guess the documentation might say something like"the input terminal takes a copy..." or this "this input will change the data given...".

So I guess my general question would be, what is the general way of knowing if something is been pass by referece or by value?

Thanks.
0 Kudos
Message 7 of 8
(5,123 Views)
Here is 2nd vi.
0 Kudos
Message 8 of 8
(5,121 Views)