LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problems with eof

Hello,

i'am beginner in LabView.
I have one VI created. This reads the data-input-file only without errors when the last CR was NOT in file. My original data-file have the last CR, and then i have not the correct output. See attachment. WHYYY???

thank you

Sascha
0 Kudos
Message 1 of 4
(3,153 Views)
Hello Poloni,

your read routine expects the last line of data without a CR/LF. If you have a CR/LF, then it reads another line - but this line is empty. So your last data will be all zero. This leads to the wrong display: display data=0 at time=0 (=01.01.1904).

So you have to check, if the last line is empty. If so delete the last data set.

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(3,140 Views)
Poloni,

One way around it would be to check of the file ends in a ("), then add a newline. This way the rest of the code can be the same.

A few suggestions:
  • If you don't want the first row, skip it at the beginning instead of cutting it out later.
  • You must initialize the first shift register with zero, otherwise you won't read anything in the second run.
  • It is not efficient to read one line at a time from the file. Read the entire file, then use scan for tokens to get the lines, and again for each line to get the items. Since each line contains a known number of elements, you can use an inner FOR loop.
  • "Remove from array" is very inefficient and not needed at all here. Simply get the desired columns using index array for all values.

    I made a few quick modifications (LabVIEW 7.0) to show some of the above points. See attached.
  • 0 Kudos
    Message 3 of 4
    (3,125 Views)
    Hi,

    THANK YOU. Your answer was very good. LabVIEW was so easy (when you know how it's works...)!

    Bye,

    Sascha
    0 Kudos
    Message 4 of 4
    (3,112 Views)