Batfastad Posted April 28, 2004 Posted April 28, 2004 I know there is a function in filemaker to generate a random number. Has anyone successfully applied this to make a script to go to a random record? All our records obviously have an id in the format II#xxxxxx where x is an updating serial number. Any ideas? Thanks
Ender Posted April 28, 2004 Posted April 28, 2004 I think this will work: Set Field [ gRandomTemp , Round(Status(CurrentRecordCount) * Random, 0) ] Go to Record/Request/Page [ gRandomTemp ]
Michael Myett Posted April 29, 2004 Posted April 29, 2004 If you have a copy of "Scriptology" there is a file called RandomPicks.fp3, on the companion CD, which chooses random records using a different technique.
Batfastad Posted May 10, 2004 Author Posted May 10, 2004 Yep just tried it - sorry for my late reply Works great! Thanks
BobWeaver Posted May 14, 2004 Posted May 14, 2004 There's a slight flaw in Ender's formula which will give a skewed distribution. The last record will only have half the chance of being picked that the other records have. Also, there is a chance the formula will return a zero value, and there is no corresponding record zero. To give a fair distribution, the round function should be replaced with Int as follows: Set Field [ gRandomTemp , Int(Status(CurrentRecordCount) * Random)+1 ] Go to Record/Request/Page [ gRandomTemp ]
Batfastad Posted May 14, 2004 Author Posted May 14, 2004 Ah right OK - excellent thanks!! Not that it really matters with 80,000+ records! Thanks
Ender Posted May 14, 2004 Posted May 14, 2004 I try to leave a bug or two in my answers as an exercise for the reader.
Steve T. Posted May 15, 2004 Posted May 15, 2004 Hi, folks! IMO BobWeaver is among the top experts at FMFORUMS and personally, I am glad for his input and corrections -- and especially his explanations when he is generous enough to provide them. He's one of the reasons FMFORUMS is so helpful to so many of us. I can think of many scenarios where not having a truly random (ha! truly random!) solution could be problematic and raise issues of liability. What if FMFORUMS randomized the ad banners w/an inaccurate function and an unhappy customer wondered why his/her banner was not showing up as much as other advertisers? Uh.. ooopss.. sorry, Stephen, maybe we shouldn't go there, eh? Anyway, you get my point, eh? So, thanx, Bob! Keep us honest and keep FMFORUMS creditable! --ST
Recommended Posts
This topic is 7758 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now