From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to Save Array and Calculations even if I close the VI

Hello Everyone
I am doing a Data System Using LabVIEW, I have finished the VI, But I am facing a problem that when i close the VI, I lose my data and Calculations, I tried to use Read From Spread Sheet, I get the old array and old data but with New Calculations not related or added to old array
How Can i fix this problem in a simple way. and here is my vi in the attachments.

0 Kudos
Message 1 of 6
(2,855 Views)

To retain data in controls and indicators, you need to do a "edit, make current values default", then save the VI.

 

(Your VI is extremely ugly and inefficient. You might want to ask for help here cleaning it up. Using local variables of controls that don't have a label is just plain dangerous! There are many things that could be done with 10% of the current code. There are many things that don't make any sense. There is nothing determining the loop timings. You constantly inserting into arrays while the array should be fixed size and you should be replacing. You only need to write the headers and define the combo string once. uninitialized shift registers are pretty meaningless here. How are you running this (continuous run button???)?

0 Kudos
Message 2 of 6
(2,845 Views)

I tried to use "make current valules default" but when i open the VI again and run it, it doesn't use the old data and start to add new data and delete the old one
and I Press Run not continuous run
also i am new to labview maybe the VI isn't that good, but it does what i want, what i want is to overcome that problem.

0 Kudos
Message 3 of 6
(2,817 Views)

Your data is partially contained in uninitialzed shift registers.

 

You really should do a few tutorials and ask advice about general code architecture. This cannot be fixed well with the current code without making an even bigger mess..

 

Properly done, the code will be 90% simpler and fit on a postcard, still with the same (and more!) functionality!

0 Kudos
Message 4 of 6
(2,802 Views)

What about that code

0 Kudos
Message 5 of 6
(2,774 Views)

NO, you still need to simplify! The least efficient way to keep a running sum is to keep prepending to a 1D array (growing without bounds!) and taking the array sum for each item. All you need is an 1D array that contains the sum  and you would increment a certain element if the numbers change. After each change, format it back into the bottom left table (Please give it a label!!!! If you don't want to see the label, you can hide it on the front panel)

 

All you need is the following:

  • A 2D string array in a shift register, initially empty, where you append a new log entry with each transaction. Use a table indicator and define the header strings.
  • 1 1D DBL array in a shift register where each element contains the sum of all items, to be displayed as explained above.

Your loop currently spins millions of times per second. It only needs to spin whenever OK is pressed. Lewarn about event structures.

The cases of your big case structure only have minor differences. You can probably combine most of the code, avoiding all these duplications.

Use an enum for the "Select" and write the strings exactly once before the loop.

Same for the table headers! These things don't need to be done over and over and over....

Your initialized arrays are too big, especially if you "insert" instead of "replace". You could just use "build array" combining the two rows.

 

To retain the data when the loop ends, write it to a file and read it on program start to initialize the shift registers.

 

0 Kudos
Message 6 of 6
(2,765 Views)