Re: FMP question
Re: FMP question
- Subject: Re: FMP question
- From: Shane Stanley <email@hidden>
- Date: Thu, 02 Nov 2000 08:59:20 +1100
On 2/11/00 6:03 AM +1000, Paul Berkowitz, email@hidden, wrote:
>
Thanks. Here it is.
There's room for improvement there. The key is to keep the number of events
to a minimum.
The first thing to do is to create a new layout (or layouts) in the database
that contains only the fields you'll be concerned about, in the order you
want to deal with them. By addressing this layout, you can simplify things
greatly.
For example, if there are seven fields you are interested in, you can do
this:
tell layout x
create new record at end with data {a, b, c, d, e, f, g}
end tell
This is much quicker than creating the record and then putting in the data
(lthough there are quicker ways still, especially if you are importing more
than a handful of records at a time).
As for your search for duplicates, you're ignoring the whose clause; let FMP
do the searching for you (using a new layout):
tell database 1
tell layout y
record 1 whose cellValue of cells = {b, f, c, d, e}
end tell
end tell
Note that this uses FMP's sloppy matching ("Johnson" will match "John") and
will give an error if no match is found. So your safest method is to do
something like:
tell database 1
tell layout y
try
set x to record 1 whose cellValue of cells = {b, f, c, d, e}
on error
set n to ""
end try
end tell
if n {b, f, c, d, e} then
tell layout x
create new record at end with data {a, b, c, d, e, f, g}
end tell
end if
end tell
That should speed things up quite a bit. But if you're going to be getting
more than a handful of records at a time, there are ways that are
considerably faster still...
--
Shane Stanley, email@hidden