From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving variables in a text file

Hi there,

 

I am using a VI which receives some variables and I'd like to save them all in a text file.

 

I would like to have a row to be added for each iteration of my while loop so that I would get, say:

first line: 2500.000000, 2502.000000, 0.000000, 2529.000000, 2488.270176, 2551.494700, 4704, 423564, 57.303482, 2016-11-10 15-38-42

second line: 2500.000000, 2502.000000, 0.000000, 2529.000000, 2488.270176, 2551.494700, 4704, 423564, 57.303482, 2016-11-10 15-38-42

 

etc

So far I've managed to save my variables in that text file, but the format of saving is not really ideal (not displayed in line, and each iteration saves the new values + everything that has been saved during the previous iterations...)

 

I've attached an example of output as well as my current VI

 

Thank you,

Flo

Download All
0 Kudos
Message 1 of 6
(3,367 Views)

Hi Flo,

 

but the format of saving is not really ideal (not displayed in line

Because you have it programmed this way: each ArrayToSpreadsheetString will add a CR/LF…

 

and each iteration saves the new values + everything that has been saved during the previous iterations...)

Because you have it programmed this way: you collect your data in arrays and each time you save the content of those arrays into your file…

 

Simple solution:

Collect only the values of the next line in an array and use ArrayToSpreadsheetString only once per line of text…

 

Best regards,
GerdW


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

The problems are in your shift registers.  You are building the individual values into multiple arrays, then combining them all together.

 

You shouldn't need any shift regsiters.  Just combine the various data coming into a single string.  Write that string to the file.

 

You didn't attach your VI, just a picture of your block diagram.  Otherwise it would be easy to fix.

0 Kudos
Message 3 of 6
(3,355 Views)

The picture is actually a snippet.

 

I'll try your solution.

 

 

thank you

0 Kudos
Message 4 of 6
(3,350 Views)

@Flo-w wrote:

The picture is actually a snippet.

 

I'll try your solution.

 

 

thank you


I'm sorry, you are right.  It is.  I didn't notice the header information at the top of the image.

 

EDIT:

Attached is a modified VI.  I cleaned up a lot and used Format Into String to simplify the combination of the data points.

Note, you will need to debug it.  I know a couple things broke such as where data was accumulated.  So you may need to add a shift register or two back in and fix where the data is coming from.  (I just added the constant of 0 to them.)

0 Kudos
Message 5 of 6
(3,331 Views)

Thank you ! I'll try that right now !

 

Flo

0 Kudos
Message 6 of 6
(3,235 Views)