1.  04/19/2007, 03:26 PM I'm not sure if any of you have seen this thread. I know Scotty has. Anyways, I'm creating an app that will randomly change your ringtone after each call. The only thing I'm stuck on now is how to generate a random number, with the following stipulations... 1. Number generated must be > 0 and < x 2. Number generated must be a rounded number. Regarding #2, I know with Mortscript 4.01 Alpha 9 has this option Round( number ), but I was hoping it would be possible with prior releases. I was thinking of using Timestamp() somehow, but I'm unsure how to make it conform with #1. I suk at math
2.  04/19/2007, 04:32 PM Well, managed to get in before the experts. n=12 'the number of files you wish to have randomized x=timestamp () 'the time stamp z=substr(x,9,2) 'grab the seconds from there r=z*n/100 'multiply the seconds by the number of files, then device by 100 y= part (r,".",1)+1 'strip of the numbers after the decimal, to round it, add 1 to get the numbers to start at 1 message (y) 'displays the number Surur Last edited by surur; 04/19/2007 at 04:39 PM.
3.  04/19/2007, 04:43 PM NICE! Thanks It will work, but the numbers coming up are always greater than the previosly generated, since it's using the seconds as part of the calculation. Although, it will work. Last edited by crazie.eddie; 04/19/2007 at 04:53 PM.
4.  04/19/2007, 04:53 PM small modification n=6 x=timestamp () tp=substr(x,9,2) z=substr(tp,2,1) & substr(tp,1,1) #reverses the order of the digits so the seed number makes larger changes quicker (ie faster than every 10 seconds) r=z*n/100 y= part (r,".",1)+1 message (y)
5.  04/19/2007, 05:15 PM Awesome! Thanks again
6.  04/21/2007, 02:27 PM Originally Posted by surur Well, managed to get in before the experts. n=12 'the number of files you wish to have randomized x=timestamp () 'the time stamp z=substr(x,9,2) 'grab the seconds from there r=z*n/100 'multiply the seconds by the number of files, then device by 100 y= part (r,".",1)+1 'strip of the numbers after the decimal, to round it, add 1 to get the numbers to start at 1 message (y) 'displays the number Surur Surur, not knocking your logic, but what was wrong with? random = ( Timestamp() MOD n ) + 1 Z.
7.  04/21/2007, 05:22 PM Originally Posted by zbop Surur, not knocking your logic, but what was wrong with? random = ( Timestamp() MOD n ) + 1 Z. Yes, my way is a longer way to do the same thing. Thats why I tried to get in before the experts Surur
8.  04/21/2007, 06:10 PM Originally Posted by surur Yes, my way is a longer way to do the same thing. Thats why I tried to get in before the experts Surur haha, well if any experts DO show up, be sure to let me know There's more than one way to skin a cat, nuthin wrong with that. BTW, it should be pointed out that either method is not random at all if (1) it is called in rapid succession, i.e. a loop, or if (2) the script is scheduled at a constant interval.
9.  04/21/2007, 06:26 PM Originally Posted by zbop BTW, it should be pointed out that either method is not random at all if (1) it is called in rapid succession, i.e. a loop, or if (2) the script is scheduled at a constant interval. This is actually a very valid point, as I think crazy.eddie is thinking of running the script every 60 seconds, which will obviously result in a very fixed pattern. With the routine being called with a (presumably) randomly times phone call it makes much more sense. Surur
10.  04/21/2007, 07:22 PM ask mortie for a RND function/feature in the next release. that's what lazy experts would do.
11.  04/21/2007, 07:52 PM Apparently its implemented in the next version, but obviously wont be back-ported to older mortscript interpreters. Surur
12.  04/21/2007, 09:31 PM Originally Posted by surur Apparently its implemented in the next version, but obviously wont be back-ported to older mortscript interpreters. Surur Cool. I've registered at the forum the other day, but I haven't received a confirmation email yet, so I couldn't put any suggestions yet.