Board index » cppbuilder » (Deleting spaces,tabs and CRLF's in RichEdit) Programm freeze when there is no printable text..
Oren Halvani
![]() CBuilder Developer |
(Deleting spaces,tabs and CRLF's in RichEdit) Programm freeze when there is no printable text..2004-05-11 12:01:54 AM cppbuilder42 hi dear builders, i found a little bug in a function that deletes CRLF's and spaces around a text in a TRichEdit.. it fails (i mean my programm freezes) when there are ONLY CRLF's but NO printable text / characters in the RichEdit.. what do i need to modify in my function to avoid it...? thanks for any help... Oren /****************************************************/ void __fastcall TForm1::cmdTrimAllClick(TObject *Sender) { RichEdit1->Lines->BeginUpdate(); try { for(int x = RichEdit1->Lines->Count-1; x>= 0; --x) { AnsiString s = RichEdit1->Lines->Strings[x].Trim(); if(s.Length() == 0) {RichEdit1->Lines->Delete(x);} else {break;} } bool test = true; while(test) { AnsiString s = RichEdit1->Lines->Strings[0].Trim(); if(s.Length() == 0) {RichEdit1->Lines->Delete(0);} else {test = false;} } for(int x = 0; x < Memo1->Lines->Count; x++) { RichEdit1->Lines->Strings[x] = TrimLeft(RichEdit1->Lines->Strings[x]); RichEdit1->Lines->Strings[x] = TrimRight(RichEdit1->Lines->Strings[x]); } } __finally { RichEdit1->Lines->EndUpdate(); } } |