LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array- Permanent Storage of array values

Hi WEvans,

you should do as Altenbach told you! (I hope I didn't forget anything...)

One more comment:
You can join all racer's information in a cluster. Then you wouldn't need the ugliest connector pane of all! (And it makes sense to collect data belonging together in a cluster anyway.)


Message Edited by GerdW on 11-21-2007 10:00 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 26
(1,841 Views)
Altenbach, what I would like this program to do is store inputs/array values (for "Venue" and "Driver Name") for future runs so the user can select these inputs from the drop down menu, instead of having to retype these items everytime they use the program.

The second loop handles a few things:
    1. Stores user's input (for "Venue" and "Driver Name") into an array so the item can become selectable from the combo box's drop down menu on next run of the                 program.

    2. It deletes repeated inputs from the array so multiply entries of the same input won't appear in the drop down menu. 

    3. This is why the read file needed to be created.  It stores the array values in a file so they can be loaded into the propertly node of "Venue" (will also want to do the                 same for "Driver Name") on next use of the program. This was needed because the array's default value (of nothing) was getting initialized at the start of the                     program (if vi was exited then re-started), so I was told. However, I have a similar vi that retains (or initializes) the previous array values from the last run when it has         been exited then re-started.... so I kind of raise an eyebrow to that theory.

I attemped to put evertying in the second loop inside the main loop and it worked fine for "Venue" OR "Driver Name". But when I tried to put the code for BOTH combo boxes, the program would get stuck in the while loop.
0 Kudos
Message 12 of 26
(1,832 Views)

Can you show us the "one loop" version? Maybe it has a simple solution. 🙂

Anyway, this is not such a complicated problem, but you should not constanty do file IO (this is only needed if everything absolutely needs to be recorded immediately so the data is retained even if the computer crashes).

Use a state machine architecture with a single loop and an event structure.

  1. At program start, read the file, check for duplicates if needed, and populate the combo boxes.
  2. Keep the current strings in a shift register, and whenever an entry is added, check for duplicates and updates the strings[] of the combo box (or ring, or whatever).
  3. It the stop case (or "panel close", etc), write the final names to the file.
0 Kudos
Message 13 of 26
(1,828 Views)
I restructured the program to have a single loop, and everthing works good except a couple issues:

1) Refering to Fig 14, the cirlced portions of the program does not seem to be able to work simultaneously. If just one portion is there... the program works fine. If both are there, the  circled portion of code  with the "x" does NOT execute (at all).

2.) Refering to "Venue text",  For some reason the program writes extra spaces between the name. This affects the the reading of the file (names will apear as a single string)  since the "spreadsheet to array.vi"  is looking for a SINGLE space.


Message Edited by WEvans on 11-29-2007 04:27 PM

Message Edited by WEvans on 11-29-2007 04:27 PM
Download All
0 Kudos
Message 14 of 26
(1,808 Views)


WEvans wrote:
I restructured the program to have a single loop, and everthing works good except a couple issues:

1) Refering to Fig 14, the cirlced portions of the program does not seem to be able to work simultaneously. If just one portion is there... the program works fine. If both are there, the  circled portion of code  with the "x" does NOT execute (at all).

2.) Refering to "Venue text",  For some reason the program writes extra spaces between the name. This affects the the reading of the file (names will apear as a single string)  since the "spreadsheet to array.vi"  is looking for a SINGLE space.

You still have ways to go.
  1. What makes you think that the code does not execute?
  2. When you do an array to spreadsheet string, you don't have the delimiter wired, thus it will insert a TAB as delimiter. Wire a space constant and things will be more as expected.

You still have many things to clean up. For example,

  1. you don't specify if opening the file or reading from the file occurs first. (first sequence frame). Use data dependency.
  2. The inner sequence structure has no purpose.
  3. Use an event structure in the loop, there is no reason to spin the loop unless something changes.
  4. You can eliminate most property nodes by using a shift register for the strings[]. This will also create a data dependency and the big sequence structure is no longer needed.
  5. You probably should update the Strings[] inside the loop so it reflects the current state. Doing this after the loop is useless.
0 Kudos
Message 15 of 26
(1,794 Views)
Ok... I changed the program and got rid of the whole deleting elements from the array part. This program actually writes data to both files (unlike the last program) however, once again I'm having a problem with the data being loaded into the Strings[] as a single string as opposed to an array of values. I tried many different types of delimiters for writing and reading the file, but none seem to change how the data is written/read to/from the file. I even tried writing to a .xls file instead of a .txt file, but still the data was read as a single string instead of an array of data. Any suggestions??
0 Kudos
Message 16 of 26
(1,765 Views)

Well, now it is an even bigger mess. 😮 You should not add sequence frames to determine execution order, but just used wires and things will fall into place. One very big No-NO! is your right-to-left wiring. That will confuse everybody! The initial reading of the files should occur on the left for clarity.

What is the purpose of OK1?

Here's a quick draft how you could do it. I did not test it so there are probably bugs everywhere, Still it should give you some ideas on how to do certain things.

Let me know if you have any questions.

Tab is a good delimiter. Space is not as good, because the name or venue could contain a space. You could also use a newline character. That would place each entry on a new line in the file.



Message Edited by altenbach on 12-01-2007 10:14 AM
0 Kudos
Message 17 of 26
(1,754 Views)
Actualy, I don't see the purpose of all these property nodes to the left and right. For example once a Vi is saved with certain values for boolean text, that change is permanent and you don't need to rewrite it all every time you call it.
 
Just call the VI with "open FP when called and close afterwards" and the rest should fall into place.
0 Kudos
Message 18 of 26
(1,745 Views)
Altenbach, preciate all your help. The RacerInfoIIedMod.vi tested good w/only one minor error. However, I was able to correct it by using Tex[] (to compare and write the new value to the file instead of "newval") and changing when the event occured. If you don't mind I like to include this vi in my project, in which case I'd need your name (or I could use "altenbach") to include in the project report. Either way, I'd least like to give credit for helping. If you'd prefer send it me an email, my email address is wldsgrtst@yahoo.com. Thanx again.
0 Kudos
Message 19 of 26
(1,714 Views)

You can find out more about the  Grand Wizard here.

Ben

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