LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading data from file in a subVI efficiently?

I wrote a LabView application that has a subVI which in turn has another subVI which needs to read data from disk to run. Since this last subVI which reads data is being called in the innermost loop of the parent VI, I am worried about the efficiency of this program. Is there any way that a VI can read data on the first execution, but from then on know that it already has this data and not reload it?

thanks for your input!
Martin
0 Kudos
Message 1 of 4
(2,833 Views)
You can create what I call a cache VI. It's sort of like a global, but is more controllable because it's written in LV. I have attached a simple example that shows what I mean. The first time its run it reads a file and puts the contents in an uninitialized shift-register. Each time after that, it simply outputs the cached value. The cache only reloads if the input file name changes.

Obviously, the logic for when to reload the cache can become arbitrarily complex. For example, the code could look at the modification date of the file and reload it if the file is modified...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 4
(2,833 Views)
thanks a lot!
i actually couldn't open your vi for some reasion (maybe my labview version 5.1 is too old for that). but your description was clear enough so i quickly implemented it and it improved my program's performance!

thanks again
martin
0 Kudos
Message 3 of 4
(2,833 Views)
Yes, the version I sent that in was 6.0. Glad that it helped. I have found that technique to be very helpful for all sorts of things. For example, an instrument driver that automatically initializes itself the first time its called...

Hollar if you have any more problems.

Mike...

PS: In the future, if you let folks know you're working in version 5, we can save examples in that format for you...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 4
(2,833 Views)