LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to programmatically search for text?

I've noticed that you can call the "Export VI Strings" functionality via invoke node on a VI reference. I'm currently experimenting to see if I can come with something using this. Essentially I'm looping through all VIs in memory, checking for the ones that are in my project folder on disk, and recreating the same directory structure in a different folder with all the exported VI strings in XML files. I could then automate searches using "grep" on that folder to find the strings I'm searching for.

 

I imagine this would actually be a faster method since exporting all the VI strings essentially serves to "index" them, making each search take seconds instead of minutes. However, I'm currently running into issues with LabVIEW crashing when exporting strings for certain VIs (isn't that always the case...) so that might put a damper on my plan.

0 Kudos
Message 11 of 16
(760 Views)

@EthanJ wrote:

I've noticed that you can call the "Export VI Strings" functionality via invoke node on a VI reference.


That will be FP only though.

0 Kudos
Message 12 of 16
(747 Views)

wiebe@CARYA wrote:

@EthanJ wrote:

I've noticed that you can call the "Export VI Strings" functionality via invoke node on a VI reference.


That will be FP only though.


There's a Boolean option on the invoke node that can be set to TRUE to also export block diagram strings. This doesn't include everything (notably, names for case structures with string selectors are not included) however it does include string constants on block diagrams, which happens to be what I'm looking for. As such, this seems to be an adequate solution for my problem. I used Grep for Windows to search recursively through all the VI string files I exported, and made a script in LabVIEW to automatically search for a number of strings, parse for string constants, and report to me how many matches there were for each search string. I compared several of these to the results of a "manual" CTRL+F text search and the results are consistent.

0 Kudos
Message 13 of 16
(738 Views)

@EthanJ wrote:

wiebe@CARYA wrote:

@EthanJ wrote:

I've noticed that you can call the "Export VI Strings" functionality via invoke node on a VI reference.


That will be FP only though.


however it does include string constants on block diagrams, which happens to be what I'm looking for. 


As long as you're only looking for string constants, the scripting solution is pretty trivial as well...

0 Kudos
Message 14 of 16
(732 Views)

wiebe@CARYA wrote:

@EthanJ wrote:

wiebe@CARYA wrote:

@EthanJ wrote:

I've noticed that you can call the "Export VI Strings" functionality via invoke node on a VI reference.


That will be FP only though.


however it does include string constants on block diagrams, which happens to be what I'm looking for. 


As long as you're only looking for string constants, the scripting solution is pretty trivial as well...


Fair point.

 

I suppose the advantage to this method is that searching through the VI strings for the 8000+ VIs on disk with Grep only takes a few seconds vs the time it takes LabVIEW to crawl through 8000+ VI references every time one wants to re-do the search operation. Conversely, the VI scripting method isn't vulnerable to changes to the code (whereas with the VI strings method, you run the risk of having your strings become out-of-sync with your code).

 

Nonetheless, it would be nice if the built-in CTRL+F text search was accessible programmatically. I do feel a bit like I'm re-inventing the wheel here since the folks at NI have already developed a tool for this. Given how much of the other UI interaction is automatize through invoke/property nodes (especially with SuperSecretSpecialStuff and the likes enabled), I'm surprised that this operation is missing.

0 Kudos
Message 15 of 16
(728 Views)

@EthanJ wrote:

Nonetheless, it would be nice if the built-in CTRL+F text search was accessible programmatically. I do feel a bit like I'm re-inventing the wheel here since the folks at NI have already developed a tool for this. Given how much of the other UI interaction is automatize through invoke/property nodes (especially with SuperSecretSpecialStuff and the likes enabled), I'm surprised that this operation is missing.


There's definitely some room for improvement there. I've been toying with the idea to make a much more flexible search (and later replace). It's not easy though. Not just the technical realization, but also designing an interface.

 

I'd like to be able to simply search all string constants, and then their content. Or all instances of a sub VI that have a certain value wired to it (when known at compile time). And so on.

 

I want to allow branching, merging, filtering, etc. on the data sets. Doable in a diagram, but making a GUI for it soon turns out to be some sort of scripting language...

0 Kudos
Message 16 of 16
(722 Views)