LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send line by line from txt file

Solved!
Go to solution

Hi

 

I am trying to create program to achieve getting each line separatlly from .txt file. I have done it using "For Loop" structure. Inside this loop I can get one by one each line from .txt file, but in outside the loop i only see the last line from the .txt file. I want to achieve possibility to get info from each line to another part of program. I want to set supplyes, meters according to command from .txt files using gpib (sending one by one). It is possible to get this info in real time outside loop or antoher good solution?

 

Thanks in advance for help

Using: LabVIEW Community Edition

2.png1.png

Download All
0 Kudos
Message 1 of 7
(1,090 Views)

It only outputs last value because you have it set that way.

 

Right click on the output node and select "Tunnel mode --> Indexing" (or concatenating, depends on what data type you want).

0 Kudos
Message 2 of 7
(1,072 Views)

I try this, but does not work as I wanted to. Even if i use indexing. The values in array appers after taht  each line will be taken in loop.

0 Kudos
Message 3 of 7
(1,064 Views)
Solution
Accepted by crossrulz

Hi Spock,

 


@mrspock wrote:

I am trying to create program to achieve getting each line separatlly from .txt file. I have done it using "For Loop" structure. Inside this loop I can get one by one each line from .txt file, but in outside the loop i only see the last line from the .txt file. I want to achieve possibility to get info from each line to another part of program. I want to set supplyes, meters according to command from .txt files using gpib (sending one by one). It is possible to get this info in real time outside loop or antoher good solution?


Simplify your VI:

 

  • You already read the file as an array of rows, so no need to read it again as a scalar string!
  • Use autoindexing tunnels to process the lines in a loop.
  • To transfer data from one loop to another part of your program you should use: notifiers, queues, channels, (functional) globals, even locals. Learn about all them, they all have advantages and disadvantages!

Your question is very basic LabVIEW stuff, so I suggest to take care of those "Training resources" listed at the top of the LabVIEW board!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(1,040 Views)

Why are you reading the file twice?  You could just autoindex on the array of lines.

 

As far as passing the line around, you could use Queues, Notifiers, or User Events to send it to whoever you think needs it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(1,035 Views)

GerdW thanks a lot for the answer and tips. Aftear reading about this synchronization functions I choose the queue operations and it works great. In attachment screenshot of the program.

 

Best regards:

Dawid

0 Kudos
Message 6 of 7
(987 Views)

Hi Dawid,

 

you don't need those UnbundleByName nodes to get the error status: you can directly OR your stop buttons with the error wire!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(965 Views)