Finding a list of things in FMPro
Finding a list of things in FMPro
- Subject: Finding a list of things in FMPro
- From: Nigel Smith <email@hidden>
- Date: Wed, 21 Jan 2004 12:06:19 +0000
Dear All,
This has come up before, but I don't remember this solution. Apologies if it
has already been mentioned...
I often want to find records in FileMaker from an AppleScript list of
variable length. For example, if I had a "FruitStock" database I might want
to find
every record whose cell "Fruit" contains any of {"apple","pear"}
So far I've been doing this by either:
unmarking all records
finding and marking every "apple" record
finding and marking every "pear" record
finding all marked records
...or:
creating a monster search with more criteria than I'll ever need
setting the first n criteria using items 1 to n of the list
leaving the other criteria to some kind of placeholder
...which is easy enough for "or" searches, but more tricky for "and"
searches.
So now I've come up with this, for a simple "or" search:
-----------
set fruitList to {"apple", "banana", "orange","pear"}
set fillString to " or cell \"fruit\" is equal to \""
set theScript to "show (every record whose cell \"fruit\" is <no-break>
equal to \"" & item 1 of theList & "\""
repeat with x from 2 to count of fruitList
set theScript to theScript & fillString & item x of fruitList & "\""
end repeat
set theScript to theScript & ")"
tell application "FileMaker Pro"
tell database "FruitStock"
show every record
run script theScript
end tell
end tell
-----------
It will handle variable length lists, and a quick play shows you can build
some pretty complicated search criteria on the fly.
Anyone else using this method? Any "gotchas" that are going to get me?
Nigel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.