Reference > Script steps reference > Editing script steps > Set Selection
 

Set Selection

Designates a selection or cursor location in a field.

See also 

Options 

Go to target field specifies the field whose contents you want to select. If no target field is specified, the active field is used.

Start Position specifies the starting position of the selection.

End Position specifies the ending position of the selection.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Partial 

FileMaker WebDirect 

Yes 

FileMaker Server 

Yes 

FileMaker Cloud 

Yes 

FileMaker Data API 

Yes 

Custom Web Publishing 

Yes 

Runtime solution 

Yes 

Originated in 

FileMaker Pro 6.0 or earlier

Description 

A position within a field is determined by the number of characters, including spaces, beginning with position 1, the first character in the field. A selection includes all values beginning with the start position and concluding with the end position. For example, if Field1 has the value "abcdefgh", and the script step options specify a start position of 3 and an end position of 6, the script step will select "cdef". If the start position is in range and the end position is out of range, then everything from the start position to the end of the field is selected. (A position is in range if it is between 1 and the length of the text in the field.)

To move the cursor without selecting text, you can specify position values that are out of range or have the end position before the start position:

 

To move the cursor

Set

Before position n

Start Position = n and End Position = 0

After position n

Start Position = 0 and End Position = n

To the start of the field

Start Position 1 and End Position = 0

To the end of the field

Start Position > m and End Position m, where m is the length of text in the field

Or set Start Position 0 and End Position < 0

Notes 

No action is taken if the user attempts to perform a selection on a container field.

Data selected out of visual range is scrolled into view.

In FileMaker Go, this script step does not highlight selected text if the keyboard is hidden on the device.

Example 1 

Selects the first 5 digits of the Postal Code field.

Set Selection [Customers::Postal Code; Start Position: 1; End Position: 5]

Example 2 

Selects the number of paragraphs that the user specifies in the custom dialog box.

Show Custom Dialog ["How many paragraphs do you want to select?"; Products::Number of Paragraphs]
If [Get ( LastMessageChoice ) = 1]
Set Selection [Products::Description; Start Position: 1; End Position: Position ( Products::Description ; ¶ ; 1 ; Products::Number of Paragraphs )]
End If

Example 3 

Moves the cursor before the third character in the field.

Set Selection [Table::Field1; Start Position: 3; End Position: 0]

Example 4 

Moves the cursor after the third character in the field.

Set Selection [Table::Field1; Start Position: 0; End Position: 3]

Example 5 

Moves the cursor to the start of the field.

Set Selection [Table::Field1; Start Position: 0; End Position: 0]

Example 6 

Moves the cursor to the end of the field.

Set Selection [Table::Field1; Start Position: -1; End Position: -1]

Related topics 

Script steps reference (alphabetical list)

Script steps reference (category list)