LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loading a file when the file is updated

Is their a way to load a file only when their is something changed in the file?

0 Kudos
Message 1 of 9
(3,111 Views)

What file are we talking about?

Text file, MS Office file, TDMS file, ... ...

 

Who saved/changed the file?

Can that system set the "Archive" bit of the file?

If yes you check the "Archive" bit and reset it.

 

Can you use the "last changed" time of the file?

0 Kudos
Message 2 of 9
(3,107 Views)

@JoVMo wrote:

Is their a way to load a file only when their is something changed in the file?


Well you're going to have to read it in some form or another to see if 'something changed in the file'..

 

What about storing the old file's size in bytes and using the 'Get File size' function to return the current size of the file in bytes. If there's a difference between your stored value and the current value, then the size of the file has changed. 

 

Of course this will only work if the file's size changes and will not work if your overwriting an existing file with similar data which may contain the same number of bytes.

 

Maybe you could provide some more details for futher solutions

0 Kudos
Message 3 of 9
(3,105 Views)

One process saves the XML file. Another process loads that file. But continuous loading of the file, finally makes the system crash due to memory underrun.

0 Kudos
Message 4 of 9
(3,099 Views)

The process that modified the XML file could also set the Archive bit of that file, right?

The other process then reads the Archive bit of the file.

 

 

The process that modfied the XML file could also create a small txt file with the name of the mofied XML file.

The other process then reads the small text file at a certain time interval instead of the XML file.

 

 

If you open and close the file correctly I don't see why you system would crash Smiley Surprised

0 Kudos
Message 5 of 9
(3,089 Views)

I can't find how to set the archive bit...

0 Kudos
Message 6 of 9
(3,084 Views)

Maybe you can start here

And also don't forget that "Google" is your friend!

 

 

To be honest I never did it using LV but even more using VB 🙂

0 Kudos
Message 7 of 9
(3,081 Views)

Using the "File Exists" vi from OpenG you could work as follow:

1) Process A modifies the XML file

2) Process A create an empty file in the same folder called e.g. "ServiceMe.txt"

3) Process B uses the "File Exists" vi to check for the "ServiceMe.txt" file

4) If file exists process B can do what he needs to do

5) if file doesn't exists, process B can have a break Smiley Tongue

 

The "File/Directory Info" VI returns, among other things, the last lodification date.
Maybe you can use this?

0 Kudos
Message 8 of 9
(3,065 Views)

The file created and writed to by process A is keeped alive the entire time. So the file exists the all process, it is just beeing updated by process A. The archive bit approach, looks complicated to implement for process A. Process A need to know when to set the bit. It's not set automatic by the filesystem.

0 Kudos
Message 9 of 9
(3,039 Views)