Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Mastering PowerBuilder

HomePrevious Lesson: Previewing & Printing Document From RTE Control
Next Lesson: Sharing DataWindow/DataStore With a RTE Control

Editing Document In RTE Control

Like any other editable control such as Multiline Edit control, RTE has a lot of editable functions such as Cut(), Copy(), Clear(), Paste(). You can call SelectAll() to select all the content of the RTE control. Similarly Undo() function also. If you enable the popup menu for the RTE control, all these options will display on the popup menu and PowerBuilder will automatically execute the appropriate operation. However, if you do not want to show the popup menu and want to control through script then you can use the above functions.

You can also search the RTE control using Find() and continue searching by calling FindNext(). Using these functions you can search in different directions i.e., forward/backward/all. You can make the search to find whole words only. You can also make the search case sensitive. These two functions Find() and FindNext() are not available on the RTE control popup menu. However FindAndReplace() function is missing for the RTE control. If you wish to provide this functionality to the user you need to write the code. The code you need to write is not that complex and you can even take the code from the example application. The following code finds and replaces all those that match the specified string. This code is taken from the Clicked event of the cb_ReplaceAll CommandButton on the w_rte_replace window. You can find this window in the pbexamw3.pbl library.
Integer	li_Loc, li_Changes
irte_1.SetRedraw(False)
If ib_FindNext Then
li_Loc = irte_1.FindNext()
Else
li_Loc = irte_1.Find(sle_find.text, True, &
Not cbx_matchcase.Checked, &
cbx_wholeword.Checked, True )
ib_FindNext = False
End If
Do While li_Loc > 0
If irte_1.SelectedLength() > 0 And &
((cbx_matchcase.Checked And &
irte_1.SelectedText() = sle_find.Text) Or &
((Not cbx_matchcase.Checked) And
Lower(irte_1.SelectedText()) = &
Lower(sle_find.Text))) Then
irte_1.ReplaceText(sle_replace.Text )
li_Changes++
Else
MessageBox("Replace", &
"This is The Exit. The Find must have failed!!!!")
Exit
End If
li_Loc = irte_1.FindNext()
Loop
irte_1.SetRedraw(True)
If li_Changes > 0 Then
MessageBox("Replace", &
String(li_Changes) + " replacements made.")
Else
MessageBox("Replace", "No replacements made.")
End If

The above code is replacing all the occurrences of the specified string. Even though the code is so long the logic is very simple. The above code is calling Find() for the first time and calling FindNext() in a loop. As you might have seen in any word processor, when your search matches a string the matched string is selected and highlighted. Then calling ReplaceText() will replace that selected (highlighted) text.
HomePrevious Lesson: Previewing & Printing Document From RTE Control
Next Lesson: Sharing DataWindow/DataStore With a RTE Control

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com