January 18, 200620 yr 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.
January 18, 200620 yr 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.
January 18, 200620 yr Author Thank you for the fast reply, I do have a question that might make me sound dumb....How do I create a custom function?
January 18, 200620 yr Or skip the CF, and just use a slightly different calc for each: FieldA = Int(Random*4)+1 FieldB = Int(Random*2)+1 etc.
January 18, 200620 yr 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.
January 18, 200620 yr Author I tried that, and I got nothing but zeros. I think I might be missing something.
January 18, 200620 yr Hey Zero, Ceiling is a good function to use here. I had forgotten about it (I've been mostly working in FM6 until recently.)
January 18, 200620 yr 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
January 18, 200620 yr 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
January 18, 200620 yr 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. :
January 18, 200620 yr ... 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
Create an account or sign in to comment