LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read .txt file every <x> seconds , scan file for changes , write changes to new file

Hello,

 

Using LabVIEW 2021 for this project.

 

 

I provided both the front panel as well as block diagram.

Front Panel: Options to Select file to scan and File to write to

Block Diagram: Picture2.png has 2 while loops in parallel, 1 with and 1 without file read delay.

Picture3.png compares the file lengths and runs a for loop for the differences between the current scan and previous scan.

 

I am having issues getting program to run and capture every change in file.

Upon startup it continuously writes the first line in the file it is reading until it captures a scan to compare it to.

It also appears to occasionally double up on some lines and prints them out multiple times, I can not seem to get the for loop to stop once it finishes running the set number "N."

 

Download All
0 Kudos
Message 1 of 8
(1,633 Views)

We cannot run and debug a code from the images. Please attach your code instead.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 8
(1,605 Views)

Here is attached VI.

0 Kudos
Message 3 of 8
(1,592 Views)

File Line Count VI Missing.

 

Have you tried using FileSystemWatcher, You can use this to trigger an event whenever there is a change in file, By which you can avoid reading the input file continuously.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 8
(1,518 Views)

Apologies.

 

Here is File Line Count VI

0 Kudos
Message 5 of 8
(1,510 Views)

Have you tried FileSystemWatcher, Too many while Loop and also all the Loops where running without any condition (Abort is the only option to stop Execution) which is not the recommended way.

 

Go through basics of state Machine architecture and try to implement in proper structured way (Application Design Patterns: State Machines - NI).

 

Also the Top Loops which reads files does the same functionality (except  wait) any specific reason?

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 8
(1,487 Views)

Was using the top loop with the wait function in order to compare to other loop to capture any changes.

 

Looking for an increase in # lines in file.

0 Kudos
Message 7 of 8
(1,476 Views)

How about something like this?

 

SizeChg.png

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 8
(1,464 Views)