哈,这个问题我正好刚研究过,而且用得蛮好。需要修改demo的源码才行,我贴出来吧:
(分数全给我噢!)
只要修改下面两个函数,我把字段定界符规定为逗号','(只为读ZoneAlarm防火墙日志
方便),你可以自己改成别的,一般用'|'做定界符。
function TTextDataSet.GetFieldData(Field: TField; Buffer: Pointer): Boolean;
var
i,n,j:integer;
pc,tmp
char;
begin
pc:=pchar(ActiveBuffer);
j:=0;
while (j<Field.Index) and (pc^ <> #0) do
begin
if pc^ = ',' then j:=j+1;
pc:=pc+1;
end;
// ActiveBuffer:=@pc;
tmp:=pc;
n:=0;
for i:=1 to Field.Size do
begin
if pc^ = ',' then break;
pc:=pc+1;
n:=n+1;
end;
// StrLCopy(Buffer, ActiveBuffer, Field.Size);
StrLCopy(Buffer, tmp, n);
Result := PChar(Buffer)^ <> #0;
end;
procedure TTextDataSet.SetFieldData(Field: TField; Buffer: Pointer);
var
i,n,j:integer;
pc,tmp
char;
begin
pc:=Buffer;
j:=0;
while (j<Field.Index) and (pc^ <> #0) do
begin
if pc^ = ',' then j:=j+1;
pc:=pc+1;
end;
tmp:=pc;
n:=0;
for i:=1 to Field.Size do
begin
if pc^ = ',' then break;
pc:=pc+1;
inc
;
end;
// i:=strlen(Buffer)-strlen(pc);
StrLCopy(ActiveBuffer, tmp, n);
// StrLCopy(ActiveBuffer, Buffer, Field.Size);
DataEvent(deFieldChange, Longint(Field));
end;