From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to loop for txt file ?

Hi all,
I would like to send the string data into txt file. I had successfully send the last string information into txt file after I stopped the operation.
Since I need to acquire the string data in live time, may I know how to loop for the txt file ?
I tried to put a while loop for txt file but it doesn't work as what I expected.
Hope to hear from you guys !
0 Kudos
Message 1 of 8
(1,034 Views)

You've got a serious data flow problem in that tiny picture of your code.  You need to look over the LabVIEW tutorials again.

 

  • You have a while loop that executes forever.  The outer while loop will never get a chance to run a second iteration.
  • That while loop runs as fast as it again doing the same thing over and over.
  • The while loop acts on the same data on every iteration.  Whatever is in the pink tunnel.

 

Start by getting rid of that inner while loop.

 

It is impossible to help more since you didn't attach your VI so we can see what is really going on in the rest of your VI.

0 Kudos
Message 2 of 8
(1,013 Views)

Here's my VI. Hope it helps. 

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

As RavensFan said, you need serious dataflow change, you have wires going all over the place. Generally it's frowned upon if the wire goes backwards (unless you are using feedback node or similar).

 

You should open file only once, at the start of your program, and then write to it and close when program stops. What you are doing here is opening the file on every loop, write a glob of data into it and then close it.

The way you concatenate strings together you just get a single string out, no spaces or line breaks or anything, that file will be very hard to read.

 

EDIT: just noticed that you also use empty error constants before each IF, that does absolutely nothing and should be removed.

0 Kudos
Message 4 of 8
(973 Views)

A cleaned up version of your code with the file handling fixed.

0 Kudos
Message 5 of 8
(939 Views)

Ah, the magic of AeroSoul_0-1620307144670.png

 

0 Kudos
Message 6 of 8
(935 Views)

Ahha, thanks ! 
I didn't know that there's a method to clean up the wiring. 

0 Kudos
Message 7 of 8
(930 Views)

Thanks alot, truely appreciated. 

0 Kudos
Message 8 of 8
(929 Views)