09-13-2014 08:35 AM
I've been through the forum, and have found a few ways to do this, but I have an array problem: I set mine up to generate the initial five numbers and a door prize-winning "powerball," but my issue is how can I get the array of five to show each number in a different cell in the array, rather than in every cell at the same time. I think I need an array constant somewhere, but with a while loop in the for loop, I can't seem to come up with the desired operation.
Here's a copy of my vi and a pic of the "spaghetti"
Also, I'm running on my version 9 student edition.
Thanks for any help.
Solved! Go to Solution.
09-13-2014 08:52 AM - edited 09-13-2014 09:04 AM
Take Index Array & do whatever you want ..
http://zone.ni.com/reference/en-XX/help/371361J-01/glang/index_array/
I have some suggetions,
1. why you kept bigger Forloop with N value "1". It's not required (if you want to execute for 1time).
2. In side For loop also same.
3. suppose if you want to change N value more than "1" then why you want Shift register for Inside for Loop ??? because your not doing anything with that value (for next itteration). Change Tunnel Mode and Select Last value.
09-13-2014 09:28 AM
There some fundamental errors in your vi.
As it has already need said, a For Loop with an 1 wired to N does not make any sens.
A Delay outside the For loop, and a delay in a For loop that only runs one time is not needed.
To your real problem, to get a array of the values that has been selected.
Wire the output from the while loop to antoher output out of the For loop that runs 5 times and select the tunnel to be Indexing. That will create an array of your values. That is the array you can display.
09-13-2014 11:03 AM - edited 09-13-2014 11:09 AM
09-13-2014 11:11 AM - edited 09-13-2014 11:12 AM
-
09-13-2014 11:12 AM - edited 09-13-2014 11:15 AM
As others have said, there are many things wrong with your code:
You are using way too much code for such a simple problem!
Here's a quick solution (5 of 59 and 1 of 35, as specified here). modify as needed.
See if you understand how it works.
09-13-2014 11:33 AM - edited 09-13-2014 11:34 AM
09-13-2014 12:45 PM - edited 09-14-2014 01:08 PM
@apok wrote:
- generate random #s up to 40
- search 1d for non repeating #s in the shift register
- AND the results with the elapsed timer and build the array
- array size = 5, stop vi.
There are several problems with your version:
here's a quick alternative of your code.
09-14-2014 06:43 AM
This is exactly what I envisioned, but I don't have the experienc to implement. Thanks so much; it's really "elegant" code. Thanks to all you LabView wizards for the variety of solutions. That is to me the best thing about LabView.
09-14-2014 09:42 AM
I think the riffle solution is cleaner. Did you try it?
The last solution is a bit inelegant and can cause problems in the more general case. For example if you would set N higher than the possible number of values, the VI would be trapped in the inner while loop forever because every possible value would be a duplicate after a while.