[求助]关于定位文本文件中的某行的问题!!!
[求助]关于定位文本文件中的某行的问题!!!
单独处理前三行或者后两行数据调试都可执行,同时处理5行数据就不会处理啦。。。
不知道是否有直接定位到文本文件中的某行,或显示当前在读的文件行数的函数可直接调用,
请做过这方面程序的朋友提一些建议,谢谢啦。。。
转换前读的格式
GSMPCL1 Vsss1.230
GSMPCL11 Vsss0.476
GSMPCL22 Vsss0.307
Avg. Burst Power (Avg.)[dBm] = 11.771870 Pass
Peak Burst Power [dBm] = 11.771870 Pass
转换以后写的格式
Ccc+Final,GSMPCL5 Vsss,value,,,1.230
Ccc+Final,GSMPCL12 Vsss,value,,,0.476
Ccc+Final,GSMPCL17 Vsss,value,,,0.307
Ccc+Final,GSM TCH 666_3_Avg. Burst Power,dBm,,,11.771870
Ccc+Final,GSM TCH 666_3_Peak Burst Power,dBm,,,11.771870
void CRWTestFileDlg::ReadWriteTxtFile()
{
CString strsour;
CStdioFile fileR,fileW;
if (!fileR.Open("TestR005.txt",CFile::modeRead))
return;
if (!fileW.Open("TestW005.txt",CFile::modeCreate |CFile::modeWrite))
return;
bool b = fileR.ReadString(strsour);;
while(b)
{
////if()//
////{
////该函数应用有问题,是否有判断某字符串中是否有某子串的函数可以调用???
if(strsour.Find("Vsss")>=0) //处理前三行数据
{
strsour.Insert(0,"Ccc+Final,"); //字符串中插入Ccc+Final,
int valuepos=strsour.Find("Vsss"); //查找Vsss在字符串中的位置
strsour.Insert(valuepos+4,",value,,,");
fileW.WriteString(strsour+'\n'); //写文件
}
else if(strsour.Find("Burst Power")>=0) //处理后两行数据
{
strsour.TrimLeft();
strsour.Insert(0,"Ccc+Final,GSM TCH 666_3_");
int powerpos=strsour.Find("Power"); //查找字符串中Power位置
int dBmpos=strsour.Find("dBm"); //查找字符串中dBm位置
strsour.Delete(powerpos+5,dBmpos-powerpos-5);
strsour.Insert(powerpos+5,",");
strsour.Insert(powerpos+9,",,,");
int equalpos=strsour.Find("="); //查找字符串中=位置
int rsimbolpos=strsour.Find("]");
strsour.Delete(rsimbolpos,equalpos-rsimbolpos+4);
int strlentemp=strsour.GetLength();
strsour.Delete(strlentemp-4,4);
strsour.TrimRight();
fileW.WriteString(strsour+'\n'); //写文件
}
/////}
b = fileR.ReadString(strsour);
}
fileR.Close;
fileW.Close;
}