How to read from a file line by line
I am new to using LabView and was wondering how I could read data from a tex
t file one line at a time and display this data one line at a time as well.
I tried looking through the Reading from Text File . vi example but that jus
t seems to be reading and d
isplaying everything together.
Leave a comment...
- 6 Comments
- Hi Karan, I'd not done this before myself. But I thought I'd have a q
uick crack at it to see what I could come up with. This VI isn't complete.&n
bsp; But it should give you some ideas. My guess is that you wanted to
split your existing text f
ile into one line text files and maybe do something with them after. T
he first screenshot should give you some ideas there. If all you want
to do is display them, the second shot does that. tachments/ni/170/230670/1/L
Vreadtextline.png"> /2/LVdisplayonelinetext1.png"> Message Edited by pallen on 02-18-2007 07:14
LVdisplayonelinetext1.png:#1; Tue, 29 Apr 2008 16:21:00 GMT
- 1... Use FILE I/O - ADVANCED - OPEN FILE, with the path to your file as an i
2... Use FILE I/O - ADVANCED - EOF to get the EOF of the file.
3... Enter a WHILE LOOP.
4... Within the loop, Use FILE I/O - READ FILE, with the refnum as an input,
and wired LINE MODE to a TRUE constant.
5... Display the string out of READ FILE.
6... Wait a while, just for visual effect, if you want to.
7... Compare the OFFSET out of the READ FILE to the EOF from step 2.
8... If OFFSET is >= EOF, terminate the loop.
9... Close the file.Message Edited by CoastalMaineBird on 02-18-2007 06:18
PM#2; Tue, 29 Apr 2008 16:22:00 GMT
I was looking at the post above this one and was just wondering how to use a
nd where to find the FILE I/O - ADVANCED- EOF function. Also, what would nee
d to be to keep track of the offset to compare it with this EOF?
-Karan#3; Tue, 29 Apr 2008 16:23:00 GMT
My aim is to read text line by line and to then go ahead and display the las
t 8 reaad lines of code to give the impression of text falling down a screen
. I tested the first while loop and that seemed to work fine. However, when
I encounter an EOF, I would
like the text already read to keep making its way down the screen and keep i
nputting NULL characters into the array to simulate the effect of the text f
alling down the screen which is why I created the second while loop. I tried
to input the NULL charact
ers using a box for ENUM constants. However, I kept getting an error saying
the data types do not match. What would I need to do? For the display I plan
on putting indicators next to the 8 places where the text would be stored w
hich I have not done so far#4; Tue, 29 Apr 2008 16:24:00 GMT
- I think you have to rethink your code from the ground up.
Why do you have two loops at all?
Just read the entire file at once (not line by line) and use a single loop t
o first display it line by line and then prepend linefeed characters (I
have no idea why you think a NULL character would scroll your text).
For some reason, you never close your file.#5; Tue, 29 Apr 2008 16:25:00 GMT
- Here's a quick draft (LabVIEW 8.0) for one possible solution. Makes sense?
Message Edited by altenbach on 03-04-2007 09:27 AM
ScrollText.png:#6; Tue, 29 Apr 2008 16:26:00 GMT