var
I,a: Integer;
flat:Boolean;
p:array[21..25]of integer;
begin
p[23]:=612;//612 //23
p[22]:=588;//588 //22
p[24]:=616;//616 //24
p[21]:=560;//560 //21
p[25]:=644;//644 //25
a:=1;
for I := 21 to 25do
// Iterate
begin
if printPosString(i,s) then
begin
a:=p;
break;
end;
end;
// for
if a=1 then
result:=p[23]
else
result:=a;
end;
function printPosString(p:integer;s:string):Boolean;
var
I: Integer;
temp:string;
len:integer;
flat:Boolean;
begin
len := ceil(length(s)/2/p);
flat:=true;
for I := 0 to len-1do
// Iterate
begin
temp:=COPY(s,0,p*2) ;
if ((Pos(')',temp)=1) or (Pos(',',temp)=1) or (Pos('。',temp)=1) or (Pos(':',temp)=1) or (Pos('(',temp)=length(temp)-1) or (Pos(':',temp)=length(temp)-1)) then
begin
flat:=false;
break;
end;
s:=copy(s,p*2+1,length( s )-p*2 );
end;
result:=flat ;
end;
终于解决了。