ReplaceSel - DfBaseRichEdit
Replaces selected text with specified text
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| sText | string | Text to replace selected text with |
Syntax
Procedure ReplaceSel string sText
Call Example
Send ReplaceSel sText
Description
Replaces selected text with sText. If no text is selected, it inserts the text at the current caret position.
This method has no effect if control is not paged.
Sample
This sample replaces the selected text in control oRichEdit1 with "Michael".
send ReplaceSel of oRichEdit1 "Michael"
Sample
This sample gets the search text from a user via Form oSearchText to variable sSearchText and the text to replace the found text from a user via Form oReplaceText to variable sReplaceText . It then performs a case-sensitive search using FindText for sSearchText in all text in the oRichEdit1 control following the current selection or cursor position. If sSearchText appears in the portion of the control's text that is searched, it is selected using the SetSel method. This sample assumes that Form or dbForm controls named oSearchText and oReplaceText exists in your code.
Procedure DoSearch
string sSearchText sReplaceText
integer iSelStart iSelEnd
// get user's search text from form
get Value of oSearchText to sSearchText
// get user's replace text from form
get Value of oReplaceText to sReplaceText
get FindText of oRichEdit1 sSearchText FR_MATCHCASE to iSelStart
// was search successful?
if (iSelStart <> -1) begin
// get length of search text
move (length(sSearchText) + iSelStart) to iSelEnd
// select search text found
send SetSel of oRichEdit1 iSelStart iSelEnd
// now, replace the selected text
send ReplaceSel of oRichEdit1 sReplaceText
end
End_Procedure // DoSearch