procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
tf : Textfile;
mobile: string;
begin if OpenDialog1.Execute then
begin
Memo1.Lines.LoadFromFile(opendialog1.filename);
assignfile(tf, opendialog1.FileName);
reset(tf);
readln(tf, mobile);
i:=0;
while mobile <> #$1A do
begin
array1[i]:=mobile;
i:=i+1;
readln(tf, mobile);
end;
end;
showmessage(inttostr(memo1.Lines.count));
end;procedure TForm1.Button1Click(Sender: TObject);
var
j : Integer;
s,st:string;
i,i5:integer;
a5:array[0..1000] of string;
begin
for j:=0 to memo1.Lines.Count-1 do
begin s:=array1[j];
st:=s;
for i5:=0 to 4 do
begin
i:=1;
while copy(st,i,1)<>' ' do
i:=i+1;
a5[i5]:=copy(st,1,i-1);
st:=copy(st,i+1,length(st)-i);
end; for i5:=0 to 4 do
begin
memo2.Lines.add(a5[i5]);
end; end;
showmessage('处理完毕');
end;
var
i:integer;
tf : Textfile;
mobile: string;
begin if OpenDialog1.Execute then
begin
Memo1.Lines.LoadFromFile(opendialog1.filename);
assignfile(tf, opendialog1.FileName);
reset(tf);
readln(tf, mobile);
i:=0;
while mobile <> #$1A do
begin
array1[i]:=mobile;
i:=i+1;
readln(tf, mobile);
end;
end;
showmessage(inttostr(memo1.Lines.count));
end;procedure TForm1.Button1Click(Sender: TObject);
var
j : Integer;
s,st:string;
i,i5:integer;
a5:array[0..1000] of string;
begin
for j:=0 to memo1.Lines.Count-1 do
begin s:=array1[j];
st:=s;
for i5:=0 to 4 do
begin
i:=1;
while copy(st,i,1)<>' ' do
i:=i+1;
a5[i5]:=copy(st,1,i-1);
st:=copy(st,i+1,length(st)-i);
end; for i5:=0 to 4 do
begin
memo2.Lines.add(a5[i5]);
end; end;
showmessage('处理完毕');
end;
while (mobile <> #$1A) and (i < 5) do
begin
array1[i]:=mobile;
i:=i+1;
readln(tf, mobile);
end;
while mobile <> #$1A do
begin
array1[i]:=mobile;
i:=i+1;
readln(tf, mobile);
end;无结束
begin s:=array1[j];// array1是否能取到memo1.Lines.Count-1 其他的看不出来有什么问题;你还是单步看看吧
ilao:真假begin
ilao:真while 文件未结束 do
begin
array1[i]:=mobile;
i:=i+1;
readln(tf, mobile);
if mobile <> #$1A then
ilao:假
强行结束循环
end;
begin
i:=1;
while copy(st,i,1)<>' ' do
i:=i+1;
a5[i5]:=copy(st,1,i-1);
st:=copy(st,i+1,length(st)-i);
end;
这段程序有问题,你的st若是'123_'(_代表空格)则没问题,若是'123'那可就死了你用这段程序试试就知道了:
var
i5,i:integer;
s,st:string;
begin
st:='123';
i:=1;
while copy(st,i,1)<>' ' do
i:=i+1;
s:=copy(st,1,i-1);
st:=copy(st,i+1,length(st)-i);
edit1.Text:=s;
edit2.Text:=st;
end;