11-20-2019 01:42 PM
I'm working on a project that needs to be able to sort through the text file and place the correct words into string boxes. What we are trying to do is use a search and split string but we cant quite figure it out. We want it to come from one text file and sort into 10 different places. For example we want to because for lab view to read the sentence; Patient has a body weight of 150 lbs. and a height of 66in. and then have strings on the block diagram with height and weight and when we run it only 150 lbs would be in the box for weight and then only 66 in would be in the box for height and so on. there are more sentences in the text file but that was just to example what we want to do . I can attach our code right now and the txt file we are working with if anyone can help.
11-20-2019 02:18 PM
I would use regular expressions and not worry about splitting the string. Simply use your various regular expressions over the entire string every time. For example, to find the body weight I would use "weight.*(\d+)\s*(\w*)$". I would use the VI Match Regular Expression and set the Multiline input to true. Expand the Match Regular Expression node to show the outputs. The first will be the weight, the second will be the units. If no units are provided the second output will be an empty string. Create the other regular expressions for the other data you are looking for. This will be more robust since it will work regardless of the order thing appear in the file.
11-20-2019 02:45 PM
Mark's suggestion is about as good as possible but be aware that slight or small variations in the spelling will introduce issues.
There is a faint voice in my memory that still remembers someone possibly on Info-LabVIEW posting many years ago that LabVIEW is good for many applications but when it comes time to write a word-processor, there may be better options.
Ben