LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with match pattern.vi and carriage return

Hello, I am fairly new to Labview so this question may seem elementary.

I am trying to read a text file containing a large number of lines (on the order of one million), each line containing 4 eight-bit numbers (in decimal format). When I read from the file it seems the match pattern.vi does not display the string following the pattern when I specify the pattern as a carriage return, or end of line. I tried to construct a simpler program using notepad files with a few numbers separated by carriage returns and it seems the same problem is occuring. Perhaps I do not understand how this vi works, but I do not encounter any of these problems when my pattern is a space or tab. (Note: I have specified nothing as far as the offset because I do not understand its function). Any help or suggestions would be appreciated. Thank you.

Andre
0 Kudos
Message 1 of 5
(4,092 Views)
Could you supply the vi you are using to read the file as well as a sample of the file, not the full million lines Smiley Wink

Cheers!
0 Kudos
Message 2 of 5
(4,089 Views)
Hello, thank you for the reply. I have created a more simple program that exhibits the same problem. I have also created a simplified file which contains two elements separated by a carriage return. (notepad file). In this situation I still cannot read the second line on the string indicator. Thanks again for your help.

Andre
Download All
0 Kudos
Message 3 of 5
(4,057 Views)

You are unlucky : there are two ways to end a text line : either with a carriage return (CR = $0D ASCII) or a line feed (LF = $0A). You should first have an idea of the separator that has been used by the writter,  and choose yours accordingly.

See the attached modified version of your vi



Message Edité par chilly charly le 11-11-2007 11:04 PM
Chilly Charly    (aka CC)
0 Kudos
Message 4 of 5
(4,045 Views)
You've got a few ways of addressing this issue.  Your file read has the conver EOL option checked (right click on the icon) which will convert all end of lines to the system system stand, which in windows is a line feed.  Your demo text file has these as carriage return/line feeds.

If you uncheck this option, then you will want to change your match pattern to match on a carriage return and line feed.

If you leave this option checked, then you need to change your match pattern to match on a line feed, not a carriage return.

What you are getting now is a no match (if you look at the index output of the match pattern, it will generate -1 indicating no match).  The Match before is actually the whole sting (you test hides this fact by only showing one line, but the whole string is there.  The match after is empty.

I did both of the above options and your Vi works as you want it.
0 Kudos
Message 5 of 5
(4,014 Views)