SelectedLength PowerScript function
Description
Determines the total number of characters in the selected
text in an editable control, including spaces and line endings.
Controls
DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit,
DropDownListBox, and DropDownPictureListBox controls
Syntax
1 |
<span>editname</span>.<span>SelectedLength</span> ( ) |
Argument |
Description |
---|---|
editname |
The name of the DataWindow, EditMask, For a DataWindow, it reports the length of the selected text |
Return Values
Integer for DataWindow, InkEdit, and
list boxes, Long for other controls.
Returns the length of the selected text in editname.
If no text is selected, SelectedLength returns
0. If an error occurs, it returns -1. If editname is null, SelectedLength returns null.
Usage
Except for text in rich text controls, the characters that
make up a line ending (produced by typing Ctrl+Enter or
Enter) can be different on different platforms. On Windows, it is
a carriage return plus a line feed and equals two characters when
calculating the length. On other platforms, a line ending is a single
character. A line that has wrapped has no line-ending character.
For DropDownListBox and DropDownPictureListBox controls, SelectedLength returns
-1 if the control’s AllowEdit property is set to false.
For rich text controls, a carriage return plus a line feed
always count as a single character when calculating the text length.
When a DropDownListBox or DropDownPictureListBox loses focus,
the selected text is no longer selected.
Examples
If the
selected text in the MultiLineEdit mle_Contact is
John Smith, then this example sets li_length to
10:
1 |
long ll_length |
1 |
ll_length = mle_Contact.<span>SelectedLength</span>() |