一文本中的内容为:
ffef weqweqwe
f wqrqwrqw
dwqdqw fwqfqwf要写成ffef weqweqwe
f wqrqwrqw
dwqdqw fwqfqwf就像在输入文本时的键盘中的tab键的效果一样,请教代码怎么写法,谢谢
ffef weqweqwe
f wqrqwrqw
dwqdqw fwqfqwf要写成ffef weqweqwe
f wqrqwrqw
dwqdqw fwqfqwf就像在输入文本时的键盘中的tab键的效果一样,请教代码怎么写法,谢谢
const
TABLEN=10;
TABSTR=' ';//10个空格
var
stringlines:TStringList;
templine:string;
i,p:integer;
begin
stringlines:=TStringList.Create;
stringlines.LoadFromFile('c:\example.txt');
for i:=0 to stringlines.Count-1 do
begin
p:=pos(' ',stringlines.Strings[i]);
if(p>0)then
begin
templine:=copy(stringlines.Strings[i],1,p-1)+ copy(TABSTR,1,TABLEN-p+1);
repeat
inc(p);
until(stringlines.Strings[i][p]<>' ');
if(p<=Length(stringlines.Strings[i]))then
templine:=templine+copy(stringlines.Strings[i],p,Length(stringlines.Strings[i])-p+1);
stringlines.Strings[i]:=templine;
end;
end;
stringlines.SaveToFile('c:\example.txt');
stringlines.Free;
end;