LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing text file

Hi everyone...

I have one question....How to write data correctly.here I post my vi to show to u all.Refer from my vi, I have create a simulation n want to save into text file.When I open the text file.It seems like it didn't write the data from string...I mean its blank only...Could anyone help me to fix it n tell me where i'm wrong here.Thank you very much...
0 Kudos
Message 1 of 7
(2,821 Views)
A couple of issues:

  • Your first WHILE loop builds a 2-D array of strings, but what you send to the file is the LAST iteration, not the collective total.
  • You shouldn't need to SET FILE POSITION more than once. Open the file, set its position to the end, then write, write, write, as needed.

    It will keep track of its own position just fine.

  • I don't understand why you WRITE until you get an error; that's almost always a bad idea. You're writing a 2-D array of strings followed by one CRLF, and then writing the SAME 2-D array, with another CRLF, and then writing the SAME 2-D array, with another CRLF.
Perhaps if you explained what it is you are trying to do...

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 7
(2,802 Views)
Oh, I get it - you want a TEXT file.

But you're writing a 2-D array of strings. If you want the file to be TEXT, you have to write TEXT. That means the data type you give to WRITE FILE has to be a STRING. Not an array of strings, but a STRING.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 7
(2,798 Views)

Use the Array to Spreadsheet String primitive from the String pallette to convert the 2D array of strings to a string [ Spreadsheet String in LV terms, Text String in normal terms ]. It ll write it into a file in Tab delimited format.

If you re using LV 8.x, the Write to File.vi will ve a polymorohic selector to select what type of array you re feeding in, o need for the Array-String conversion. Smiley Wink It ll do by itself internally.

Try it out.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 4 of 7
(2,790 Views)
Don't overcomplicate things. All you need is a "write to spreadsheet file" connected to the output shift register.
 
Also, your "OR False" in the lower right is a WEQ. It serves no purpose. The function is the same as a plain wire.
 

Message Edited by altenbach on 09-27-2007 06:54 AM

0 Kudos
Message 5 of 7
(2,784 Views)
Thanks 4 ur all suggestions....I make it complicated...n doesn't realize that I'm writing a 2-D array to write file....so..i try write to spreadsheet file.vi to remove it.n It works now...but sometimes when i try write to the other file,It seems like it didn't write the data from array.like the situation before.why does it happen?. n how exactly the way to choose and  open the  file after we simulate it.sorrySmiley Happy coz I'm still need to learn more about this..thank u very much...
0 Kudos
Message 6 of 7
(2,764 Views)
As said before, you are only sending the last line out of the first while loop, and not the accumulated array. Then, in the second while loop, you are writing the same line over and over There is no data difference between iterations.
 
Remember, LabVIEW is based on dataflow. These two loops don't run at the same time. The second loop must wait until the first loop is finished, at which point the last data line exits the tunnel you have wired out. You might want to run your VI using execution highlighting to see how things work.
 
If you want to continuously save data as it arrives, both operations need to be in the same loop.
 
Sorry, I don't understand the rest of your question.
0 Kudos
Message 7 of 7
(2,755 Views)