Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 15 of 15
  1. #1
    Join Date
    Jul 2008
    Posts
    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.

  2. #2
    Join Date
    Apr 2007
    Posts
    175
    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.

  3. #3
    Join Date
    Jul 2008
    Posts
    17
    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

  4. #4
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    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.

  5. #5
    Join Date
    Jul 2008
    Posts
    17
    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.

  6. #6
    Join Date
    Jul 2007
    Posts
    158
    Quote 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);

  7. #7
    Join Date
    Jul 2008
    Posts
    17
    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.

  8. #8
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    Here's a quick & dirty example that should get you started.
    Not the greatest of examples but... here you go.
    Attached Files

  9. #9
    Join Date
    Jul 2007
    Posts
    158
    I Strongly recommend to use TextAnimation action like the example attached.
    Attached Files

  10. #10
    Join Date
    Jul 2008
    Posts
    17
    @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.

  11. #11
    Join Date
    Jul 2007
    Posts
    158
    Quote 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.

    Quote 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.

  12. #12
    Join Date
    Jul 2008
    Posts
    17
    @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.

  13. #13
    Join Date
    Jul 2007
    Posts
    158
    Come on friend, you can do it yourself, just a little thinking

  14. #14
    Join Date
    Jul 2008
    Posts
    17
    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.

  15. #15
    Join Date
    Jul 2007
    Posts
    158
    Quote 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);
    if draw_no > 100 and draw_no < 150 then	
    	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 at 04:00 AM.

Similar Threads

  1. Example: Serial Number Generator
    By Roboblue in forum AutoPlay Media Studio 7.5 Examples
    Replies: 13
    Last Post: 10-31-2008, 09:27 PM
  2. Random Number Generator W/ Check
    By markstaylor in forum AutoPlay Media Studio 6.0
    Replies: 12
    Last Post: 09-18-2006, 12:31 PM
  3. LCD Character Generator - Freeware
    By Protocol in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 12-21-2004, 12:32 PM
  4. Draw page before view
    By Nuts in forum AutoPlay Media Studio 5.0
    Replies: 1
    Last Post: 02-26-2004, 02:42 PM
  5. Fun password generator
    By Bruce in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 05-13-2003, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts