Random
12/20/2011 The purpose of this file is to show you another way to generate a random number within FileMaker Pro but with a specific requirement. That requirement is I only want single digits as the result opportunity.
The Standard Way
Using standard built-in functions ( no custom functions ), you can learn the default way to generate a random number but even better you can learn the exact limits of the random function within FileMaker.
Single Digit Random Number
How to generate your own random number with the possible results of “0″, “1″, “2″, “3″, “4″, “5″, “6″, “7″, “8″, “9″ which is really ten numbers? Let’s go!
- Brian Ginn
About the author - Brian is a founding member of the Kentuckiana FileMaker Users Group. He is a regular contributor of content at the regular meetings. He is an accomplished FileMaker developer as he works in the private sector as an independent consultant to businesses. Contact Brian via email brian@brianginn.com or cell (502) 550-0092 direct.
Reference
“FileMaker Pro 10.0v3 addressed an issue where the “Random” calculation function could generate non-random values on certain machines. The “Random” calculation will now generate values greater than or equal to 0 and less than 1. The value will never be 1.
In versions prior to FileMaker Pro 10.0v3, the “Random” function returns “a random number between zero and one” including “zero and one”.”
FileMaker URL reference web link
I want a single digit random number. To get it I simply use the Random function but I add the Middle function to wrap it in. I ask the Middle function to start at the second value because the first is a period. I ask the Middle function to get one value as the second parameter. I command FileMaker via a script to give me a random number of one of the following: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ( that gives me ten single digit numbers which I can then use in other ways within FileMaker. How?
Take the Middle ( text ; start ; numberOfCharacters ) in the form:
SetField [ table1::data21 ; Middle ( Random ; 2 ; 1 ) ]
NOTE: You could use: Right ( Random ; 1 ) but you’d never get a opportunity for a zero and therefor only nine possible digits instead of ten.
QR Code to this post:

Easy access from your mobile.

