S
sadnui
Unregistered / Unconfirmed
GUEST, unregistred user!
{ 想写一个程序 无奈不能使用Tlist(EXE出来太大了 )
弄一个小巧的tlist 处理小数据使用
封装一个类 调用也比较方便
弄了一晚上 只能弄出个函数集合
如果有兴趣的话可以帮助增强一些功能 改进代码
薄分100相送 希望广大高手出手相助 }
///////////////////////////////////////////////////////////
unit list;
interface
procedure add(str:string);
procedure del(str:string);
function count: integer;
function GetStr(i:integer): string;
function FindStr(str:string): integer;
var List: array of string;
implementation
function UpperCase(const S: string): string;
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= 'a') and (Ch <= 'z') then Dec(Ch, 32);
Dest^ := Ch;
Inc(Source);
Inc(Dest);
Dec(L);
end;
end;
{procedure add(str: string): Bool;
var
J: Integer;
begin
Result := False;
for J := Low(List) to High(List) do if (List[J] = sName) then Exit; // 排除重复
SetLength(List, Length(List) + 1); // 增加表项
List[High(List)] := sName;
Result := True;
end; }
procedure add(str: string);
begin
SetLength(List, Length(List) + 1); // 增加表项
List[High(List)] := str;
end;
procedure del(str: string);
var
i,J: Integer;
begin
if Length(List)=0 then exit;
for J := Low(List) to High(List) do
if (UpperCase(List[J]) = UpperCase(str) ) then
begin
for i := j to High(List)-1 do List:=List[i+1] ;
SetLength(List, Length(List) - 1);
exit;
end;
end;
function FindStr(str:string): integer;
var
i,J: Integer;
begin
if Length(List)=0 then exit;
for J := Low(List) to High(List) do
if (UpperCase(List[J]) = UpperCase(str) ) then
begin
Result := J;
exit;
end;
end;
function count: integer;
begin
Result := Length(List);
end;
function GetStr(I:integer): string;
begin
if count>0 then Result :=list[0] ;
end;
initialization
SetLength(List, 0 ); // 增加表项
finalization
end.
//★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
弄一个小巧的tlist 处理小数据使用
封装一个类 调用也比较方便
弄了一晚上 只能弄出个函数集合
如果有兴趣的话可以帮助增强一些功能 改进代码
薄分100相送 希望广大高手出手相助 }
///////////////////////////////////////////////////////////
unit list;
interface
procedure add(str:string);
procedure del(str:string);
function count: integer;
function GetStr(i:integer): string;
function FindStr(str:string): integer;
var List: array of string;
implementation
function UpperCase(const S: string): string;
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= 'a') and (Ch <= 'z') then Dec(Ch, 32);
Dest^ := Ch;
Inc(Source);
Inc(Dest);
Dec(L);
end;
end;
{procedure add(str: string): Bool;
var
J: Integer;
begin
Result := False;
for J := Low(List) to High(List) do if (List[J] = sName) then Exit; // 排除重复
SetLength(List, Length(List) + 1); // 增加表项
List[High(List)] := sName;
Result := True;
end; }
procedure add(str: string);
begin
SetLength(List, Length(List) + 1); // 增加表项
List[High(List)] := str;
end;
procedure del(str: string);
var
i,J: Integer;
begin
if Length(List)=0 then exit;
for J := Low(List) to High(List) do
if (UpperCase(List[J]) = UpperCase(str) ) then
begin
for i := j to High(List)-1 do List:=List[i+1] ;
SetLength(List, Length(List) - 1);
exit;
end;
end;
function FindStr(str:string): integer;
var
i,J: Integer;
begin
if Length(List)=0 then exit;
for J := Low(List) to High(List) do
if (UpperCase(List[J]) = UpperCase(str) ) then
begin
Result := J;
exit;
end;
end;
function count: integer;
begin
Result := Length(List);
end;
function GetStr(I:integer): string;
begin
if count>0 then Result :=list[0] ;
end;
initialization
SetLength(List, 0 ); // 增加表项
finalization
end.
//★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆