salberg Posted March 6, 2001 Posted March 6, 2001 I have a list of 1000 potential jurors. I need to be able to select, say 100, random jurors and put them into a separate database. Eventually, the unused jurors will return to the 1000 potential jurors. I have tried using RANDOM but the Random field must be able to be recalculated at will and also I can't get it to create unique integers. (Geaorge, I sorry. Ididn't explain myself very well.)
TyGuy Posted March 6, 2001 Posted March 6, 2001 You can use the following formula to create random numbers between 1 and 1000 in a calculation: Round(Random*1000, 0) The next thing to to would be to use this number to select a potential juror (by ID number I'm assuming) to be added to your new database. Make the ID unique so that you can compare the data (such as a concantenation between the random number and a social security number or other unique data - "136-892-34-2902" etc. You could then use another sub-routine to compare the potential juror with those already added to your database. Perhaps the best way would be to set up a relationship between the two files (using the selection date or something like that) so that you can use a global field from the first database in a sub-script nested in the second database. You could use a global field like PotentialJuror in the first database and a Loop sub-script to compare the potential juror to all those selected and add it if it was unique. You could also use copy-paste without having to set up a relationship.
salberg Posted March 6, 2001 Author Posted March 6, 2001 Thanks for the help. I think I can get it now. The concatenation idea really helped. I modified the Round(Random*1000, 0)formula to make sure there wasn't a 0. Now its just a matter of finishing the last 2 paragraphs. Again, Thanks. quote: Originally posted by TyGuy: You can use the following formula to create random numbers between 1 and 1000 in a calculation: Round(Random*1000, 0) The next thing to to would be to use this number to select a potential juror (by ID number I'm assuming) to be added to your new database. Make the ID unique so that you can compare the data (such as a concantenation between the random number and a social security number or other unique data - "136-892-34-2902" etc. You could then use another sub-routine to compare the potential juror with those already added to your database. Perhaps the best way would be to set up a relationship between the two files (using the selection date or something like that) so that you can use a global field from the first database in a sub-script nested in the second database. You could use a global field like PotentialJuror in the first database and a Loop sub-script to compare the potential juror to all those selected and add it if it was unique. You could also use copy-paste without having to set up a relationship.
Newbies Nearo Posted March 6, 2001 Newbies Posted March 6, 2001 Here's another approach. 1.)Add a number field to the database. Call it "Selected". 2.)Add a global number field. Call it gRandom Add a summary field. Call it Total Selected. Sum(Selected) 3.)Write the following script: Loop Set field ["gRandom", "Round(Random * 1000 +1, 0)"] Go to Record/Request/Page "gRandom" Set Field ["Selected", 1] End Loop If(Total Selected = 100) End Loop Run this script. It will find 100 random records, mark each one with a "1". The summary field will keep count and cause the script to exit after 100 entries (no duplicates this way). Next, just export these records to a text file or import from your other database.
salberg Posted March 8, 2001 Author Posted March 8, 2001 It worked like a charm. Thanks for the help and the education. I have used Alpha4 and the old DB3. FMP is just another learning curve. Again, thanks for the help. quote: Originally posted by Nearo: Here's another approach. 1.)Add a number field to the database. Call it "Selected". 2.)Add a global number field. Call it gRandom Add a summary field. Call it Total Selected. Sum(Selected) 3.)Write the following script: Loop Set field ["gRandom", "Round(Random * 1000 +1, 0)"] Go to Record/Request/Page "gRandom" Set Field ["Selected", 1] End Loop If(Total Selected = 100) End Loop Run this script. It will find 100 random records, mark each one with a "1". The summary field will keep count and cause the script to exit after 100 entries (no duplicates this way). Next, just export these records to a text file or import from your other database.
Recommended Posts
This topic is 8931 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