LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to search a text file for a keyword?

Solved!
Go to solution

So I would like to implement an ability of my VI to open a text file and then using some kind of search function, locate and highlight a keyword that the user enters. Pretty much like when you hit Ctrl F in your internet browser and other places. 

 

I've tried List Folder Function, but that only says whether a file you name is in a certain location. And I've tried Match Pattern but that only splices the file into before and after segments of where the keyword is. 

 

Is there a better function to do this?

0 Kudos
Message 1 of 3
(4,587 Views)

Hi Orta,

 

so you know how to open and load a (text) file. And you already know a function you can use to search for keywords.

What else do you need?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(4,551 Views)
Solution
Accepted by topic author ShogunOrta

You can use a while loop and a shift register to go through the text using the Match pattern function. If you find a match, you can go to next iteration and use a new offset value. You also need to check when you finished searching the string. This should be a simple task to program. Try to do it, and if you find problems to solve this, upload your VI here (not a screenshot!) so people can help you...

 

edit: something like this can help:

 

match2.png

0 Kudos
Message 3 of 3
(4,549 Views)