HampMac Posted May 20, 2004 Posted May 20, 2004 This seems like this would be fairly basic, but I'm really struggling. I'm making a photo database as a tutorial project. I'd like to be able to categorize each photograph in a record with a user-editable pull down menu value list (i.e. landscape, seascape, portrait, etc.). Then on a different layout I'd like to have a global preference field that offers the same category value list, but in the form of a check box entry that would allow multiple entries. Then I'd like to write a script that says, perform a find on the category field based on the multiple checked entries in the preference global categories field, and then from that found record list pick a photograph at random to display at startup. Well I'm having trouble moving the values from my preference global category field to the category field and setting up multiple finds in the category field. I know that I could hard code this as a nested if query, but any new values added by the user would not be included. Has anyone dealt with this issue? I can handle the random issue, but this find is killing me. Thanks for your help.
Fenton Posted May 20, 2004 Posted May 20, 2004 Since both fields, the global and the regular text field are using the same value list, you could do this with a relationship between them. No need to go into Find mode or parse out the lines into separate requests (which would be the alternative approach). Just: Commit Record [no dialog] Go To Related Record [ Show, global relationship ] As far as picking one of the results at random, that's a whole 'nother operation. The main problem there is getting a number near the "range" of found records, so you don't have lots of misses. It will have to be in Loop, 'cause the best you can do is get within a range of ten. Int (Random * 10) will produce a number from 0 to almost 10. Now, I'm no mathematician, but I once built a little file to do raffles, and came up with something like this calculation (unstored), to limit the range to within a number RangeEnd (this is just so you can see it work, reset the RangeEnd to see it recalculate). Case ( RangeEnd = RangeEnd; Int ( Random * 10^( Length(RangeEnd))) + 1; Int ( Random * 10^( Length(RangeEnd))) + 1 ) In a script, it would be more like (Pick_g is global number field): If [ not IsEmpty [ "global relationship::field with data" ]
HampMac Posted May 20, 2004 Author Posted May 20, 2004 Thank you very much for your suggestion. Handling it as a relationship is brilliant. You are the man. I was too caught up trying to make a find work, but a relationship would be a great way to handle this. Thanks again.
Recommended Posts
This topic is 7493 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