CharLeft, CharLeft()

Syntax

CharLeft [Count] [Select]

CharLeft([Count] [Select])

Remarks

The CharLeft statement moves the insertion point or the active end of the selection (the end that moves when you press SHIFT+LEFT ARROW) to the left by the specified number of characters.

Argument

Explanation

Count

The number of characters 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, CharLeft moves the insertion point Count–1 characters to the left of the selection.

Nonzero Text is selected. If there is already a selection, CharLeft moves the active end of the selection toward the beginning 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, CharLeft shrinks the selection. In a selection made from right to left, it extends the selection.


If there is a selection, CharLeft 1 changes the selection to an insertion point positioned at the left end of the original selection.

The CharLeft() 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 left.

–1

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


Examples

This example moves the insertion point five characters to the left. The If conditional determines whether there is a selection. If there is a selection, the CharLeft 1 instruction changes the selection to an insertion point at the left end of the selection before moving the insertion point five characters to the left. This ensures that the insertion point is moved five characters whether or not there is a selection.


If SelType() = 2 Then
    CharLeft 1
    CharLeft 5
Else
    CharLeft 5
End If

The following example selects the current paragraph and then shrinks the selection by one character, so that the paragraph text is selected, but not the paragraph mark. You might want to do this if you need to copy the text of a paragraph but not its paragraph formatting, which is stored in the paragraph mark.


EditGoTo "\Para"
CharLeft 1, 1

See Also

CharRight, SentLeft, SentRight, WordLeft, WordRight