Re: Finding a list of things in FMPro
Re: Finding a list of things in FMPro
- Subject: Re: Finding a list of things in FMPro
- From: Andrew Oliver <email@hidden>
- Date: Wed, 21 Jan 2004 13:05:18 -0800
You seem to be going about this in a very longwinded way. Admittedly,
Filemaker's find handling isn't intuitive, but it's a lot easier than what
you're trying.
The following code snippet will find all records whose cell 'fruit' contains
either 'Apple' or 'Pear':
tell application "FileMaker Pro"
set cell "fruit" of request 1 to "Apple"
set cell "fruit" of request 2 to "Pear"
find
end tell
You can build an unlimited(?) number of requests to build a complex 'or'
search.
For an 'and' search, you simply set multiple cells in the same request. This
request will fins all records whose 'fruit' is 'Apple' and whose 'Variety'
is 'Granny Smith":
tell application "FileMaker Pro"
set cell "fruit" of request 1 to "Apple"
set cell "variety" of request 1 to "Granny Smith"
find
end tell
By combining them them in the same request (request 1) they become an 'and'
request.
Andrew
:)
On 1/21/04 4:06 AM, "Nigel Smith" <email@hidden> wrote:
>
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.
_______________________________________________
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.