Clear

Deletes selected text or an OLE object from the specified control, but does not store it in the clipboard.

To

Use

Clears selected text in a control

Syntax 1

Clears selected text, including table grids, in RichTextEdit controls

Syntax 2


Syntax 1: For selected text

Description

Deletes selected text or an OLE object from the specified control, but does not store it in the clipboard.

Applies to

DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, DropDownPictureListBox, OLE controls, and OLEStorage objects

Syntax

objectname.Clear ( )

Argument

Description

objectname

One of the following:

  • The name of the DataWindow control, EditMask, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox or DropDownPictureListBox from which you want to delete (clear) selected text.

  • The name of an OLE control or storage object variable (type OLEStorage) from which you want to release its OLE object.

If objectname is a DropDownListBox or DropDownPictureListBox, its AllowEdit property must be true.


Return value

Integer for DataWindow, InkEdit, and list boxes, Long for other controls.

For edit controls, returns the number of characters that Clear removed from objectname. If no text is selected, no characters are removed and Clear returns 0. If an error occurs, Clear returns -1.

For OLE controls and storage variables, returns 0 if it succeeds and -9 if an error occurs.

If objectname is null, Clear returns null.

Usage

To select text for deleting, the user can use the mouse or keyboard. You can also call the SelectText function in a script.

To delete selected text and store it in the clipboard, use the Cut function.

Clearing the OLE object from an OLE control deletes all references to it. Any changes to the object are not saved in its storage object or file.

Clearing an OLEStorage object variable breaks any connections established by Open or SaveAs between it and a storage file (when Open or SaveAs is called for the OLEStorage object variable). It also breaks connections between it and any OLE controls that have called Open or SaveAs to connect to the object in the storage variable.

Examples

If the text in sle_comment1 is Draft and it is selected, this statement clears Draft from sle_comment1 and returns 5:

sle_comment1.Clear()

If the text in sle_comment1 is Draft, the first statement selects the D and the second clears D from sle_comment1 and returns 1:

sle_comment1.SelectText(1,1)
sle_comment1.Clear()

This example clears the object associated with the OLE control ole_1, leaving the control empty:

integer result
result = ole_1.Clear()

This example clears the object in the OLEStorage object variable olest_stuff. It also leaves any OLE controls that have opened the object in olest_stuff empty:

integer result
result = olest_stuff.Clear()

See also

ClearAll

Close

Cut

Paste

ReplaceText

SelectText

Syntax 2: For RichTextEdit controls

Description

Deletes selected text, but also removes any table grids in the selection when the gridFlag argument is set to true.

Applies to

RichTextEdit

Syntax

objectname.Clear (gridFlag)

Argument

Description

objectname

Name of the RichTextEdit control

gridFlag

Boolean that determines whether table grids in selected text are deleted along with the selected text. Values are:

  • TRUE -- Table grids in the current selection are deleted along with the selected text.

  • FALSE -- (Default) Performs exactly as Syntax 1, deleting selected text for RichTextEdit controls, but not any table grid lines in the selection.


Return value

Long. Returns the number of characters removed from the RichTextEdit control.

Usage

Use to remove table grid lines along with any selected text. If the whole text of a table row is selected, Clear (true) deletes the text and the grid line for this row. If only some of the text in a table row is selected, Clear (false) deletes the selected text only.

See also

ClearAll