06-26-2015 11:23 AM
Hi,
I am new to Labview and I am trying to output a text file line by line. For example if my text file is
START
SETRPM 1000
WAIT 10s
RAMP RPM linear,1000,2000,2 MAF linear,5,7,2
WAIT 5s
RAMP RPM sine,2000,1500,3 MAF sine,7,3,3
END
I want it to output
START
SETRPM 1000
SETMAF 5 ...and so on
I tried modifying this code provided by Altenbach but it is still not working as I want it to. Can anyone direct me toward how I can fix this?
Thank you!
06-26-2015 11:31 AM
06-26-2015 11:41 AM
@ni359 wrote:
I tried modifying this code provided by Altenbach but it is still not working as I want it to. Can anyone direct me toward how I can fix this?
Thank you!
I would prefer if you don't associate my name with some random code, especially after you modify it.
If you refer to any code I have posted in the past, you need to always include a link to my old post to retain proper context. Thanks!
06-26-2015 12:17 PM - edited 06-26-2015 12:25 PM
Sounds good. Sorry about that, this was my first time posting in here. I did not mean to take credit for work I did not fully do, thats why.
Here is the link: http://forums.ni.com/t5/LabVIEW/How-to-read-from-a-file-line-by-line/m-p/479838/highlight/true#M2306...
06-26-2015 12:33 PM
Yes, that very old post is for a very different task.
You want to read the entire file and then display it line-by-line with some delay between lines. As has been suggested, set the file read mode to "read lines" and then autoindex on a FOR loop, appending each new line to the existing string contained in a shift register. The string terminal needs to be inside the loop.
See how far you get.
06-26-2015 02:24 PM
I think I am not incrememnting to the next line and I am not quite sure how to fix this.
06-26-2015 02:41 PM
The File Read belongs IN the loop.
Then wire in a 1 so that it reads 1 line at a time.
06-26-2015 02:59 PM
Your program does exactly what you asked it to do. In particular, it will repeat 10 times, at one per second, reading (and storing in String) the (unchanging) data that you bring in on the Shift Register. This data will consist of the first line of the (assumed-)multi-line file you specified.
I suppose your question is "Why is it only showing me one line?" This is where it really pays to "Read the Directions Carefully" (or, in this case, carefully read the Help for Read from Text File).
Bob Schor
P.S. -- I pointed your code at a text file of 7 lines on my PC. When I made a few small changes (including doing away with the silly For loop that shows the same thing over and over) , I got out an array, size 7, containing the lines of text.
06-26-2015 03:10 PM - edited 06-26-2015 03:11 PM
Wire a -1 to the number of lines to read all and then autoindex on the FOR loop, appending the new line (incl. linefeed) to the existing lines. No need to wire N.
06-29-2015 08:49 AM
Thank you Bob for the feedback.
I reviewed the help for the "Read from Text File" and yes, there were some info that I didnt catch before.
I followed the steps you gave, however I wanted the lines to display one after the other, so I probably still needed a loop.
Thanks for the help!