LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

newbie question on a lottery vi

Solved!
Go to solution

You're right. I don't think it takes into account a repeat number, unless that's covered by the array, which I wasn't able to index properly to get it to work. I'm liking apok's solution. I think I can add functionality for the powerball number by generating like the first and expanding the OR gate.

0 Kudos
Message 11 of 17
(1,406 Views)

@hungryhobbit wrote:

You're right. I don't think it takes into account a repeat number, unless that's covered by the array, which I wasn't able to index properly to get it to work.


What is "it"? What is "covered by the array"? What did not work? Show us what you did.

The riffle solution also guarantees that there are no repeat numbers.


@hungryhobbit wrote:

 I think I can add functionality for the powerball number by generating like the first and expanding the OR gate.


What do you mean by that? The powerball number can be indentical to one of the five other ones, so no comparison is needed. Why would you need an OR function? Please show us your code instead.

 

 

0 Kudos
Message 12 of 17
(1,389 Views)

It hasn't been mentioned yet, but I noticed your labels are all missing, both on the front panel and block diagram for controls.  Don't do this, it is like making a variable but not giving it a name in a text based language.

0 Kudos
Message 13 of 17
(1,378 Views)

Sorry, I apologize for being so vague. What I meant to say was: I could not see in your while loop where it generates a sixth random number. I built your "quick alternative" code exactly as you laid it out, but it required an "element" input for the Search 1D array, and no matter what value I put in it, it didn''t work.

My other comment was regarding the OR gate. As I said, "newbie." And thank you for your patience. This is, like, my third post in here, ever. There are others who choose to be pricks less than civil about less than masters.

My other comment was about apok's solution and the OR gate. As I said, I couldn't see it generating a 6th number of a different numeric range, so I was going to add another for loop to do that, but now I know that's not needed for a single number to be spit out separately from the while loop, as it would having nothing to compare to.

I will try to implement that and see how it goes.

0 Kudos
Message 14 of 17
(1,342 Views)

Okay, I've got a working solution. It's not very eloquent, but it works, for anyone who wants to use it.

I'm sure there are practices I could have used, like a sequence structure or others, but it does what I want it to do.

 

0 Kudos
Message 15 of 17
(1,301 Views)

Hi hobbit,

 

I'm sure there are practices I could have used, like a sequence structure or others

No, you don't want sequences. You don't need them…

 

Please

- DON'T delete the label of controls. Never! Hide them in the FP, but DON'T DELETE them!

- A loop run only once (either FOR or WHILE) doesn't make sense. Remove it. Use DATAFLOW to ensure correct execution order: error clusters preferred…

- Why do you need your "super number" presented in an array? Why not use a scalar numeric indicator?

- When something depends on a condition: use a CASE structure. Using a FOR loop to run zero or one time is quite "creative"…

- Using funny colors in the BD even for the "main" space (not just to highlight some loops/structures is IMHO unattractive

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 17
(1,291 Views)
Solution
Accepted by topic author hungryhobbit

Gerd already pointed out some important things. Note that your ugly diagram background maked the boolean wire basically invisible. Not good!

 

  • I am not sure why you went back to the very flawed code where the time between numbers can vary, depending on the number of duplicates found.
  • You again forgot the +1, creating random numbers where zero is a possibility and the highest number never occurs.
  • If you would configure the VI to clear indicators when called, you would not need the init to default.
  • I would generate all numbers in an instant, then play them back slowly for display if desired.
  • Use a string indicator so missing numbers don't show as zero
  • ...

Here's one possibility (LabVIEW 9.0)....

 

Download All
Message 17 of 17
(1,273 Views)