|
똑같이 List Index Out of Bound 에러네요
"//에러 처러 부분" 이라고 작성하신 부분 잘 보세요
i+7이 Count보다 큰 경우만 들어가네요
반대로 코딩해야 할듯 한데...
if((i+7) < StrLst->Count )
....
그럼..
아자! 님이 쓰신 글 :
: void __fastcall TForm1::ComThread1PacketReceived(TObject *Sender,
: : : AnsiString &buffer)
: : : {
: : :
: : : buffer = "$test,,,,,,1,,,,M,,M,,*66\r\n$head,,,,,,V,N*64\r\n$speed,,V,2,3,4,5,6,7,8,9,,N*53\r\n";
: : : //Memo1->SelText = buffer + "\r\n";
: : : TStringList *StrLst = new TStringList();
: : : StrLst->CommaText = buffer;
: : :
: : : for(int i=0; i<StrLst->Count; i++)
: : : {
: : : if(StrLst->Strings[i].Trim() == "") StrLst->Strings[i] = "0";
: : : if(i+7 >= StrLst->Count ){// 에러 처리 부분
: : : if((StrLst->Strings[i].AnsiCompare("$test"))== 0 )//& StrLst->Strings[7] == "1")
: : : {
: : : VrUserLed3->Active = true;
: : : Edit4->Text = StrLst->Strings[(i-1)+3]+"."+StrLst->Strings[(i-1)+2];
: : : Edit5->Text = StrLst->Strings[(i-1)+5]+"."+StrLst->Strings[(i-1)+4];
: : : }
: : : else if((StrLst->Strings[i].AnsiCompare("$speed"))== 0)
: : : {
: : : Edit3->Text = StrLst->Strings[(i-1)+7]*1.8;
: : : }
: } // if(i+7 >= StrLst->Count ){
: : : }
: : : Memo1->Text = StrLst->Text;
: : : delete StrLst;
: : : }
:
: 이렇게 에러 처리를 해도 에러가 발생하네요. 왜 그런건지 이유를 못찾고 있습니다.
: 처음에 몇번 되다가 또 에러가 발생하구요..
|