在c:\mydoc\mylog.log 文件,具体内容是:
CDR|1|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|0|unconnected
CDR|2|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|60|unconnected
CDR|3|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|50|unconnected想读取第一行的unconnected前的0
想读取第二行的unconnected前的60
想读取第三行的unconnected前的50也就是按行去取想要的数据,然后显示出来。
CDR|1|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|0|unconnected
CDR|2|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|60|unconnected
CDR|3|2d ef 02 6e 56 ba 1a eb 0c cb 36 c5 49 3a 73 25|50|unconnected想读取第一行的unconnected前的0
想读取第二行的unconnected前的60
想读取第三行的unconnected前的50也就是按行去取想要的数据,然后显示出来。
之前到倒数第二个“|”之间的数吗??,要是这样直接判断取出不就行了:)
如:
var
StrList:TStringList;
tmpStr:String;
StrList:=TStringList.Create;
StrList.LoadFromFile('c:\mydoc\mylog.log');
if StrList.Count<=0 then Exit;
for i:=0 to StrList.Count-1 do
begin
tmpStr:=StrList.Strings[i];
在这里处理tmpStr,可以用Copy和Pos这两个函数。
end;