Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to display a random record

Featured Replies

I am creating a quiz from a db in which each record has the following fields:

1- street names (question)

2- location (answer)

3- hint

4- map (container)

I have created layouts displaying:

1-street name only (question)

2-street name & hint

3-street name & map

4-street name, location & map (answer)

I need to display each next question (street name) in a random order and I cannot seem to create a script that will do this.

Is a script the way to do this or do I need a different approach ?

Any help would be appreciated, I have firefighters who need to learn their streets and this will help them do it in non-alphebetical order !!

Thanks, joefire

Edited by Guest

First you need to get a random number. FileMaker has the Random function that generates a random number from 0 to 1; you can employ it to get a random integer from 1 to desired range:

Int( Random *  ) + 1




To go to a random record make a global field Record # and write a script:




Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]




To display all the records in random order you need a loop:




Loop

Exit Loop If [ Status( CurrentFoundCount ) = 0 ]

#

Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]

#

# Do your stuff here, i.e. display the first layout, then go to hint, etc.

#

Omit Record

End Loop

  • Author

Thanks for the quick reply, I will try this.

  • Author

Thank you, this worked very nicely !

I didn't need the loop as I will have only one record (question) show at a tme and a button for this script that will take me to next random record.

Question:

Will this script eventually take me through all 680 records without repeating too often.

Here is what I'm using:

Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]

Go to Layout ["Streetonly"]

Thanks again

It will follow the law of large numbers, meaning that the distribution of repeats will approach some constant as the number of experiments (people taking the quiz) grows.

In order to make a more precise prediction, we would need to know how many questions are there in a quiz. For example, if there are 10 questions in total, and a quiz requires a person to answer 2 questions, the probability of getting the same question twice is 10%. If the quiz requires 3 questions, then the probability increases to 19%.

  • Author

Thanks so much for all your help. I added the capability to go to the next street alphabeticaly just in case some wish to be more methodical.

There are 680 streets which are divided about evenly into four districts. They may be studied all together or by district. I dont know if those are large numbers but I will have to test to check the repeats.

Thanks to all !

Edited by Guest
Spelling

I am afraid you may have misunderstood my remark.

First, the "large numbers" bit referes to the number of quizzes taken, not the number of questions in a quiz. You cannot predict whether a question will repeat during a single quiz; you can only predict the AVERAGE result of a large number of quizzes.

Next, in order to make such prediction, we need to know not only the number of possible questions, but also how many question will be actually asked; obviously, if only one question is asked, the chances of a repeat are zero; if more than 680 questions are asked, repetition is certain; in-between, the probability rises on a curve from 0 to 100%.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.