LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

question about listbox

I have recreate my sample file as a string constant (see attached code), I use "spreadsheet string to array" to form an array, however, it seems that the array I got is a 3 by 1 array, how can i get the 3 by 3 array? 

Mike 

0 Kudos
Message 11 of 15
(486 Views)
You simply have to use the correct delimiter. You have an empty string as a delimiter and in the string constant, the delimiter is a single space. The delimiter is different in your text file. One thing you should be doing to solve these simple problems yourself is to always have context help turned on (from the Help menu). As you move your mouse over a function, you will get a help window displayed with that function in it. There will be a link there called Detailed Help. NI has put a lot of effort into creating the help file It is meant to be used. Smiley Wink
0 Kudos
Message 12 of 15
(473 Views)

Hi, I have changed the delimiter as "space constant", I can get the 3 by 3 array, but how about when the data source has more than one space, then i will get some empty column in the array, are there any way I can get the array without any empty column. attached is the modified code.

Mike

 

0 Kudos
Message 13 of 15
(467 Views)

On the string palette, besides all of the fixed constants, is one just called String Constant. Place that on the block diagram and with the text tool inside the constant, press the space bar on your keyboard. If you need double spaces, press the space bar twice. If you need a different character, press that character on the keyboard.

0 Kudos
Message 14 of 15
(459 Views)
Mike,

You cannot expect the Spreadsheet String to Array functions to work if the string uses the same characters for delimiters and data. In your data.txt file it appears that double spaces are used as field separators but double spaces also exist in the data (in the last line "RPLL FOF "). Most lines end with double space which will produce an empty column and not all lines have the same number of fields. If you do not have control over the format of the file, you are going to have a tough time decoding the file programatically.

If you have control of the file format, change the delimiter to tab or comma or go to fixed field widths.

Lynn
0 Kudos
Message 15 of 15
(443 Views)