Database Reference
In-Depth Information
CODERS' CLINIC: POSITIONING THE INSERTION POINT
You can use the Set Selection script step to put the insertion point anywhere in a field, too. The
trick is to make sure nothing gets selected. When you specify a Start Position and an End Position,
FileMaker selects the characters at each position, plus anything in between. If these two numbers are
the same, then FileMaker selects just one character.
But what if the End Position comes before the Start Position? When you set the End Position one
number lower than the Start Position, FileMaker doesn't select anything. Instead, it puts the little
flashing insertion point right before the Start Position. Using this technique, you can get your script
to put someone anywhere you want inside a field, say at the beginning of a Notes field, so she can
just start typing, without needing to move the cursor.
Editing Field Data
Editing field data is such an important part of FileMaker that it gives you 15 ways to put data
in fields with a script step. In Chapter 11 , you learned that the scripted process for finding re-
cords could actually be shorter and more efficient than the manual process. Editing field data
via scripts is also different from manually editing data, and the following sections cover
those differences.
The first thing to understand is that, except for Set Field and Set Field by Name , the
steps in this section work only if the field is on the current layout . This is no problem for
scripts you use to structure data entry, but it can be a roadblock in other cases. Suppose you
have a script that sets a “Paid in Full” flag on an invoice. You want this script to work no
matter what layout you're on (as long as it's one that shows invoice records), and whether or
not the field is on that layout. In that case, you need to use the Set Field script step (or its
power-user partner, Set Field by Name ).
Avoiding Cut, Copy, and Paste
Your first inclination might be to use Cut , Copy , and Paste in a script to move data from one
field to another, and it usually works. You can, for example, have a script copy the Customer
ID field, go to the Invoices layout, create a new invoice and then paste it into the Customer
ID field there.
But most developers don't use this approach for two reasons. First, many developers con-
sider people's Clipboards to be sacred ground. They argue you should never change what's
on the Clipboard unless someone asks you to. So it would be OK to have a Copy button by
the Address fields, for example, that copies the address to the Clipboard because the person
would know exactly what's going into the Clipboard. But what if he manually copies a long
product description to the Clipboard and then runs the “Create Invoice for Customer” script?
Search WWH ::




Custom Search