Data Access Worldwide Knowledge Base
Article ID 2310 Article Title HOWTO: Use an Edit Object for Displaying Information and Automatically Cleanup Old Status Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2310 KBase Category VDF12 Date Created 05/09/2007 Last Edit Date 05/09/2007
Article Text
QUESTION:
I would like to use an Edit object to show information about a process to the user. But at a certain moment in time I want to have the object automatically clean up older lines of information. How can I do that?
SOLUTION:
After adding a line of information you can check how many lines there are and if this exceeds the desired number of information lines, delete N lines from the top. The following subclass does this.
Class cAutoClearTextEdit Is A cTextEdit
Procedure Construct_Object
Forward Send Construct_Object
Property Integer piMaxLines -1
Property Integer piLinesToErase 1
End_Procedure
Procedure AppendTextLn String sText
Forward Send AppendTextLn sText
Send CleanUp
End_Procedure
Procedure CleanUp
Integer iMaxLines iLines iLength
Integer iLinesToErase iLineCount
Get piMaxLines To iMaxLines
If (iMaxLines > -1) Begin
Get Line_Count To iLines
If (iLines > iMaxLines) Begin
Get piLinesToErase To iLinesToErase
For iLineCount From 1 To iLinesToErase
Get LineLength 0 To iLength
Send SetSel 0 (iLength + 1)
Send Cut
End
Send End_Of_Data
End
End
End_Procedure
End_Class
Instead of erasing lines automatically after adding a new line you could call the cleanup from time to time.
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.