WordRight, WordRight()

Syntax

WordRight [Count,] [Select]

WordRight([Count,] [Select])

Remarks

The WordRight statement moves the insertion point or the active end of the selection (the end that moves when you press CTRL+SHIFT+RIGHT ARROW (Windows) or COMMAND+SHIFT+RIGHT ARROW (Macintosh)) to the right by the specified number of words.

Argument

Explanation

Count

The number of words to move; if less than one or omitted, 1 is assumed.

Select

Specifies whether to select text:

0 (zero) or omitted Text is not selected. If there is already a selection, WordRight moves the insertion point Count–1 words to the right of the selection.

Nonzero Text is selected. If there is already a selection, WordRight moves the active end of the selection toward the end of the document.

In a typical selection made from left to right, where the active end of the selection is closer to the end of the document, WordRight extends the selection. In a selection made from right to left, it shrinks the selection.


Note that Word includes spaces following a word as part of the word. However, Word counts punctuation, tab characters, and paragraph marks as "words."

The WordRight() function behaves the same as the statement and also returns the following values.

Value

Explanation

0 (zero)

If the insertion point or the active end of the selection cannot be moved to the right.

–1

If the insertion point or the active end of the selection is moved to the right by any number of characters, even if less than Count. For example, WordRight(10) returns –1 even if the insertion point is only three words from the end of the document.


Example

This example counts the number of words (including punctuation, tab characters, and paragraph marks) in the selection and then displays the result in a message box:


EditBookmark "CountMe", .Add
SelType 1
While CmpBookmarks("\Sel", "CountMe") = 6 \
        Or CmpBookmarks("\Sel", "CountMe") = 8
    WordRight
    count = count + 1
Wend
EditGoTo "CountMe"
EditBookmark "CountMe", .Delete
MsgBox "There are" + Str$(count) + " words in the selection."

See Also

CharRight, SelectCurWord, SentRight, WordLeft