Lucky Draw No Generator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • hus2020
    Forum Member
    • Jul 2008
    • 17

    Lucky Draw No Generator

    Hi,

    Please help me with this simple program.I want to create a lucky draw no generator.These are the requirements:

    1) User enters the range of numbers to generate
    2) The system generates a no and displays to the user
    3) The no that is already displayed should no longer be in the range

    p/s:I managed to get the basics like using the Math.Random function but i dont know how to delete the no that is already displayed.Also i could not create a option for user to enter the range.


    Please Help.TQ.
  • Teqskater
    Forum Member
    • Apr 2007
    • 175

    #2
    you should generate those numbers and put them into a table that is called for example: generatednumbers
    then you display one number and then delete it from that table.
    and the repeat the process until it doesnt hold any numbers or so.

    I dont have time to create an example but i hope it works.

    Comment

    • hus2020
      Forum Member
      • Jul 2008
      • 17

      #3
      Iit would be very nice of you if you could post a sample code since I am not very good in this.I can only understand if the task is in the help file.TQ

      Comment

      • mwreyf1
        Indigo Rose Customer
        • Aug 2004
        • 417

        #4
        You should at least post what YOU have done so far so that it will be easier to see what YOU are trying to do.

        Comment

        • hus2020
          Forum Member
          • Jul 2008
          • 17

          #5
          This is what i have figured so far.

          Code:
          draw_no = Math.Random(100);
          Dialog.Message("The Lucky Draw No is :", draw_no)
          Still have no idea about how to exclude the no that is already generated.Please help me.TQ.

          Comment

          • arb
            Indigo Rose Customer
            • Jul 2007
            • 163

            #6
            Originally posted by hus2020 View Post
            This is what i have figured so far.

            Code:
            draw_no = Math.Random(100);
            Dialog.Message("The Lucky Draw No is :", draw_no)
            Still have no idea about how to exclude the no that is already generated.Please help me.TQ.
            I hope this help you

            Code:
            --Put this on Global Functions
            GeneratedNumbers = {};
            
            --This is your main code
            draw_no = Math.Random(100);
            TBCount = Table.Count(GeneratedNumbers);
            
            if TBCount == 0 then
            	Table.Insert(GeneratedNumbers, 1, draw_no);
            	Dialog.Message("The Lucky Draw No is :", draw_no);
            else
            	NumFind = false;
            	for i,j in GeneratedNumbers do
            		if draw_no == j then NumFind = true; end
            	end
            
            	if not NumFind then 
            		Dialog.Message("The Lucky Draw No is :", draw_no);
            		Table.Insert(GeneratedNumbers, TBCount+1, draw_no);
            	end
            end
            
            --Use this to see all generated numbers
            Dialog.Message("Generated numbers so far", Table.Concat(GeneratedNumbers, "\r\n", 1, TABLE_ALL), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

            Comment

            • hus2020
              Forum Member
              • Jul 2008
              • 17

              #7
              thx bro...your code really worked great.Now i think that it would be better if we let the user key in the total no(ie the no of lucky draw tickets sold) and then randomize that no.Also i want the generated numbers to be shown big to the user not in a small dialog box.Is it possible???How???TQ.

              Comment

              • holtgrewe
                Indigo Rose Customer
                • Jul 2002
                • 779

                #8
                Here's a quick & dirty example that should get you started.
                Not the greatest of examples but... here you go.
                Attached Files

                Comment

                • arb
                  Indigo Rose Customer
                  • Jul 2007
                  • 163

                  #9
                  I Strongly recommend to use TextAnimation action like the example attached.
                  Attached Files

                  Comment

                  • hus2020
                    Forum Member
                    • Jul 2008
                    • 17

                    #10
                    @arb..thx alot for all ur help.I checked the apz that u attached.There are only 2 problems:

                    1) When i click the button,i get an error(see screenshot)


                    Does it require any additional plugin?

                    2) If the total no of tickets is 5;sometimes i have to press the button more than once to get the lucky number.I understand that it is checking for duplicate with generated ones.But is it possible to do a smarter checking.This will avoid the user from pressing the button more than once.

                    Thank you again for all ur support.

                    Comment

                    • arb
                      Indigo Rose Customer
                      • Jul 2007
                      • 163

                      #11
                      Originally posted by hus2020 View Post
                      @arb..thx alot for all ur help.I checked the apz that u attached.There are only 2 problems:

                      1) When i click the button,i get an error(see screenshot)


                      Does it require any additional plugin?
                      Here is the action plugin you looking for.

                      Originally posted by hus2020 View Post
                      2) If the total no of tickets is 5;sometimes i have to press the button more than once to get the lucky number.I understand that it is checking for duplicate with generated ones.But is it possible to do a smarter checking.This will avoid the user from pressing the button more than once.
                      You can change the maximum number of random action or set a limitation manually to generate a number between two specific numbers.

                      Comment

                      • hus2020
                        Forum Member
                        • Jul 2008
                        • 17

                        #12
                        @arb thx alot...downloading the plugin solved my problem.Also tried the text zoom effect which is wonderful.

                        I was wondering that is it possible to give have the option to enter the range of tickets sold.

                        Please consider the scenario below:

                        1) Ticket no 1-100 : sold
                        2) Ticket no 101-150 : not sold
                        3) Ticket no 151-200 : sold

                        So in this case, ticket no 101-150 should not be included in the draw.Is it possible?How?

                        Thank you.

                        Comment

                        • arb
                          Indigo Rose Customer
                          • Jul 2007
                          • 163

                          #13
                          Come on friend, you can do it yourself, just a little thinking

                          Comment

                          • hus2020
                            Forum Member
                            • Jul 2008
                            • 17

                            #14
                            its not that....i am not into softwares...i am actally a mechanical engineer....its just that i started using this software and found out to be interested in it....but as u see i am a totally novice...I can only acheive my tasks if it is described properly in the ams help.So if you could guide me that would be great.TQ.

                            Comment

                            • arb
                              Indigo Rose Customer
                              • Jul 2007
                              • 163

                              #15
                              Originally posted by hus2020 View Post
                              its not that....i am not into softwares...i am actally a mechanical engineer....its just that i started using this software and found out to be interested in it....but as u see i am a totally novice...I can only acheive my tasks if it is described properly in the ams help.So if you could guide me that would be great.TQ.
                              All right then, it's the best way to learn using ams and i hope this code help you out:

                              Code:
                              draw_no = Math.Random(1, 200);
                              [COLOR="Red"]if draw_no > 100 and draw_no < 150 then[/COLOR]	
                              	Page.ClickObject(this);
                              else
                              	TBCount = Table.Count(GeneratedNumbers);
                              	if TBCount == 0 then
                              		Table.Insert(GeneratedNumbers, 1, draw_no);
                              		Label.SetVisible("Label1", false);
                              		Label.SetText("Label1", draw_no);
                              		Label.SetVisible("Label1", true);
                              		TextAnimation.Counter("Label1", 50, "", 0);
                              	else
                              		NumFind = false;
                              		for i,j in GeneratedNumbers do
                              			if draw_no == j then NumFind = true; end
                              		end
                              	
                              		if not NumFind then 
                              			Label.SetVisible("Label1", false);
                              			Label.SetText("Label1", draw_no);
                              			Label.SetVisible("Label1", true);
                              			TextAnimation.Counter("Label1", 50, "", 0);
                              			Table.Insert(GeneratedNumbers, TBCount+1, draw_no);
                              		end
                              	end
                              	Paragraph.SetText("Paragraph1", Table.Concat(GeneratedNumbers, "\r\n", 1, TABLE_ALL));
                              end
                              Last edited by arb; 08-04-2008, 04:00 AM.

                              Comment

                              Working...
                              X