LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array- Permanent Storage of array values

To whom may be able to help,

The following may not be the best method of programming, but it seemingly works with a minor problem. The array values are not permeantly saved in the array. In otherwords, when I exit LabVIEW all array values are cleared. This problem only exist with the "Race Info XI.vi". The "Combo box input.vi" array values do remain once the program is exited. I've had this problem before with the "Race Info XI.vi" and I just rebuilt the vi and it worked. For some reason, that method of rectification is not working this time. Any suggestions?



P.S. "Race Info XI.vi" is an altered "pop-up dialog box" which is part of a bigger program.


Message Edited by WEvans on 11-14-2007 05:12 AM
Download All
0 Kudos
Message 1 of 26
(5,026 Views)
Hi WEvans,

when you load a vi new into memory all controls and indicators are set to their default values!
Either you save the values from last run into a file on disc and load the data back at vi start or try to change the default values (which is only possible on a non-running vi).
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 26
(5,012 Views)

I agree with what Gerd wrote.

I discuss various methods of saving and restoring program states in this Nugget.

That Nugget may give you some ideas.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 26
(4,995 Views)

Hey guys,

I attempted to save the array values to a file and reload the file to the vi. As my knowledge of LabVIEW is extremely basic, my idea worked but not quite how I wanted it to. My first problem (which I'm just now realizing, so haven't attempted to solve) is I need to create a file to save my array values to, ONLY IF, the file doesn't already exist. Next (if the file exist) I would like to load the data into the "Strings []" property node array, which I have accomplished except with one problem. The data in the file gets loaded into the array as a single string (with spaces between the names, see fig 1) instead of multiple strings making a list in the combo box (fig 2). If you could give me some suggestions (avoiding "Event Structures...as I've tried mulitple times to use them to no prevail), it'd be greatly appreciated.

Download All
0 Kudos
Message 4 of 26
(4,969 Views)
That's happening because you're using the Read Characters from File VI, which reads the entire contents of a file into a single string. You can use the "Spreadsheet String to Array" to convert the space-delimited string into an array. You didn't provide the code of how you're saving the data. I mention this only because if you're saving the data with EOL delimeter, then you can just use the Read From Spreadsheet File directly.


Message Edited by smercurio_fc on 11-16-2007 03:42 PM
0 Kudos
Message 5 of 26
(4,945 Views)
Appreciate the help, but I'm not sure how to change the "array type" (not format type) to output a "1-D array of string" instead of a "1-D array of single [32-bit  real (~6 digital precision)]". I've tried to using a "byte to string.vi" conversion, but nothing gets outputted when connected to a indicator. Also do you know a vi that will open a file, if the file path exist, or create the file if it doesn't??
0 Kudos
Message 6 of 26
(4,915 Views)


WEvans wrote:
Appreciate the help, but I'm not sure how to change the "array type" (not format type) to output a "1-D array of string" instead of a "1-D array of single [32-bit  real (~6 digital precision)]".
This is just a diagram constant. Right-click the array element (not the array container!) and select "replace". Now navigate to the string palette and select the string constant.
 
Viola! 🙂
0 Kudos
Message 7 of 26
(4,910 Views)


WEvans wrote:
Also do you know a vi that will open a file, if the file path exist, or create the file if it doesn't??

Just use "open/create/replace" from the file palette and choose operation "open or create". Here's how it looks in 8.5.
 

 


Message Edited by altenbach on 11-17-2007 01:55 PM
0 Kudos
Message 8 of 26
(4,909 Views)
I've tempted all the wonderful suggestions, but do to my lack of programming skills (using LabVIEW) my vi is stuck in a loop.  If someone could share some knowledge on how to better organize (i.e what "structures", order of operations, etc..) it'd be greatly appreciated.
0 Kudos
Message 9 of 26
(4,851 Views)
You need to learn the basic of dataflow.
  1. In the main while loop, you are reading the same old file every 50ms? Why? Is there any other program that can change its contents at runtime?
  2. The sequence structure is useless, because dataflow if fully determined by the file reference.
  3. creating a file for reading seems silly, because it will be empty anyway.
  4. The second loop depends on data from the first loop (the boolean), thus it cannot start until the main loop has stopped.
  5. The second loop is not needed, because either:
    1. the boolean is true and the loop stops right away
    2. the boolean is false and the loop can never stop, but will perform the same operation over and over forever.
    3. Remember that there is no control inside the loop, so once the boolean enters the loop, the wire value inside the loop can never change!
  6. You should keep your code consistent. It is NOT a good idea to have duplicate diagram constant (e.g. the file name). One is enough, just branch the wire.

Could you explain what the program is actually supposed to do? Whatever it is, it can probably be done wiht half your code.

0 Kudos
Message 10 of 26
(4,845 Views)