📄 class_stringlist.pas
字号:
unit class_stringlist;
interface
function GetStringsCount(sl:string):integer;
function GetStringss(sl:string;ii:integer):string;
procedure DeleteString(var sl:string;ii:integer);
function GetStringIndex(sl,v:string):integer;
implementation
{function Trim(const S: string): string;
var
I, L: Integer;
begin
L := Length(S);
I := 1;
while (I <= L) and (S[I] <= ' ') do Inc(I);
if I > L then Result := '' else
begin
while S[L] <= ' ' do Dec(L);
Result := Copy(S, I, L - I + 1);
end;
end;}
function GetStringsCount(sl:string):integer;
var i:integer;
s:string;
begin
result:=0;
s:=sl;
if s='' then exit;
if copy(s,length(s)-1,2)<>#13#10 then
s:=s+#13#10;
while true do
begin
i:=pos(#13#10,s);
if i<=0 then exit;
result:=result+1;
s:=copy(s,i+2,length(s));
end;
end;
//ii:0到count-1
function GetStringss(sl:string;ii:integer):string;
var i,j:integer;
s:string;
begin
result:='';
s:=sl;
if s='' then exit;
if copy(s,length(s)-1,2)<>#13#10 then
s:=s+#13#10;
j:=0;
while true do
begin
i:=pos(#13#10,s);
if i<=0 then exit;
j:=j+1;
if ii=j-1 then
begin
result:=copy(s,1,i-1);
break;
end;
s:=copy(s,i+2,length(s));
end;
end;
//ii:0到count-1
procedure DeleteString(var sl:string;ii:integer);
var i,j:integer;
s,t:string;
begin
s:=sl;
if s='' then exit;
if copy(s,length(s)-1,2)<>#13#10 then
s:=s+#13#10;
j:=0;
t:='';
while true do
begin
i:=pos(#13#10,s);
if i<=0 then break;
j:=j+1;
if ii<>j-1 then
begin
t:=t+copy(s,1,i+1);
end;
s:=copy(s,i+2,length(s));
end;
sl:=t;
end;
//-1 不存在,0--count-1
function GetStringIndex(sl,v:string):integer;
var i,j:integer;
s,t:string;
begin
result:=-1;
s:=sl;
if s='' then exit;
if copy(s,length(s)-1,2)<>#13#10 then
s:=s+#13#10;
j:=0;
while true do
begin
i:=pos(#13#10,s);
if i<=0 then exit;
j:=j+1;
t:=copy(s,1,i-1);
if t=v then
begin
result:=j-1;
break;
end;
s:=copy(s,i+2,length(s));
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -