Samantha Mattie Posted January 18, 2006 Posted January 18, 2006 I want to make a layout with fields labeled A through K. I have that done, and now here is where what I want gets a little strange. I want to pull up a number 1-4 randomly in field A, in feild be random 1-2, field C 1, field D, E, F, G with random numbers 1-4, field H 1-2, Field I 1-23, and so on. Now, I don't know where to begin doing this, I was hoping that this was possible and someone out there knows how to accomplish it.
mr_vodka Posted January 18, 2006 Posted January 18, 2006 Hi Samantha, My suggestion to you would be to create a Custom Function. You can name the Cust Function something like, RandomFilter. The Cust Function will need one Parameter. Let's call it NumValues. Then use this formula. Let ( [ r=Random; // Genterates Random Number f=Filter ( r ;NumValues ); // Filters the Random Number for characters only specified in NumValues Parameter x=Left ( f ; 1 ) // Takes only the first digit ]; x ) Now In your field defintions, you need to have you number fields (A-K), with calculated value (not calculations) and also with the option to 'Do not replace existing value' Checked. The calculated value will now be a simple call to the new cust function: Field A = RandomFilter (1234) Field B = RandomFilter (12) Field C = 1 (This one doesnt need the function call because it is always one) Field D = RandomFilter (1234) etc etc etc.
Samantha Mattie Posted January 18, 2006 Author Posted January 18, 2006 Thank you for the fast reply, I do have a question that might make me sound dumb....How do I create a custom function?
Ender Posted January 18, 2006 Posted January 18, 2006 Or skip the CF, and just use a slightly different calc for each: FieldA = Int(Random*4)+1 FieldB = Int(Random*2)+1 etc.
Zero Tolerence Posted January 18, 2006 Posted January 18, 2006 Sorry to bust in here. Ender, why do you use the Int(Random*4)+1 ? I generally use Ceiling(Random * 4) Is there something with this that will not give me what I'm wanting? This has just got me a bit worried that my random Generated Numbers aren't working as I planned.
Samantha Mattie Posted January 18, 2006 Author Posted January 18, 2006 I tried that, and I got nothing but zeros. I think I might be missing something.
Ender Posted January 18, 2006 Posted January 18, 2006 Hey Zero, Ceiling is a good function to use here. I had forgotten about it (I've been mostly working in FM6 until recently.)
comment Posted January 18, 2006 Posted January 18, 2006 Ceiling(Random * 4) is good - if you want a random integer between 1-4, inclusive. I tend to use the same formula as Ender, simply because it is a subset of the general formula for generating a random integer between LOW and HIGH, inclusive: Int ( Random * ( HIGH - LOW + 1 ) ) + LOW
Samantha Mattie Posted January 18, 2006 Author Posted January 18, 2006 Thanks Zero, this was what I was looking to do.
Zero Tolerence Posted January 18, 2006 Posted January 18, 2006 Ahh I see what you mean, I'm breathing easier now!
Lee Smith Posted January 18, 2006 Posted January 18, 2006 Thank you for the fast reply, I do have a question that might make me sound dumb....How do I create a custom function? You have to have the Developer edition of FileMaker, FMI changed the name of Developer with the release of version 8 to Advance. As you see by the replies, it isn't always necessary to have the CF ability. Lee
mr_vodka Posted January 18, 2006 Posted January 18, 2006 Sorry Lee, My head has been in the clouds today. That is the second overlook that I have had. I should go home. I am sick as a dog with the flu. :
Lee Smith Posted January 18, 2006 Posted January 18, 2006 ... that is the second overlook that I have had. No sweat, it appeared that between us all everything had been covered except the question about how to do a CF. Sorry you don't feel good, when i catch that stuff, it knocks be off my feet longer than most, even if I do stay home. Lee
Recommended Posts
This topic is 6886 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