Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6886 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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.

Posted

Or skip the CF, and just use a slightly different calc for each:

FieldA = Int(Random*4)+1

FieldB = Int(Random*2)+1

etc.

Posted

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.

Posted

Hey Zero,

Ceiling is a good function to use here. I had forgotten about it (I've been mostly working in FM6 until recently.)

Posted

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

Posted

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

Posted

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.

:

Posted

... 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.