PDA

View Full Version : Generate a predetermined number.


MaaQ
02-15-2007, 03:18 PM
I want to create a program in autoplay media studio which can generate a given text or password. For instance: the program has 100 given codes like "SP1HK8KADA8D" or any other text. When i press a generate button it sould generate a random code form the 100 given codes. It can't be the same as the last code...

Also: I'm a noob at AMS.

Sorry for my broken english :P

bule
02-15-2007, 03:50 PM
codes={"iugz56erzti", "345345345","345345345","985th85eu"}; --and so on

random=Math.Random(1, Table.Count(codes));
randomcode=codes[random];

MaaQ
02-15-2007, 04:06 PM
I don't get it :s It's my first experience with code. Should i copy the code to the generate button or the input box?

bule
02-16-2007, 12:13 AM
Table codes contains all the codes. You might hardcode this table or load it from a file on disk via TextFile.ReadToTable() command. In my example I hard-coded it. This part would go on the page's On StartUp event.

The other two lines do the actual randomization. First line creates a random number between 1 and the amount of entries in the table. You would put this code on your button.

What you need next is to somehow display this randomcode variable content to the end user. You might put the password into input field via Input.SetText() command or display it using Dialog.Message().

MaaQ
02-16-2007, 07:27 AM
It works! Thank you for your help... I really appreciate it.