Function NewTxt(mite:integer):integer;
Var
F : Textfile; {定义 F 为 Textfile}
FileName:string;
Begin
if not FileExists(ExtractFilePath(ParamStr(0))+'1.txt')
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'1.txt';
mite:=1
end
else if FileExists(ExtractFilePath(ParamStr(0))+'1.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'2.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'2.txt';
mite:=2
end
else if FileExists(ExtractFilePath(ParamStr(0))+'2.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'3.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'3.txt';
mite:=3
end
else if FileExists(ExtractFilePath(ParamStr(0))+'3.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'4.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'4.txt';
mite:=4
end
else if FileExists(ExtractFilePath(ParamStr(0))+'4.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'5.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'5.txt';
mite:=5
end
else if FileExists(ExtractFilePath(ParamStr(0))+'5.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'6.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'6.txt';
mite:=6
end
else if FileExists(ExtractFilePath(ParamStr(0))+'6.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'7.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'7.txt';
mite:=7
end
else if FileExists(ExtractFilePath(ParamStr(0))+'7.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'8.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'8.txt';
mite:=8
end
else if FileExists(ExtractFilePath(ParamStr(0))+'8.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'9.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'9.txt';
mite:=9
end
else if FileExists(ExtractFilePath(ParamStr(0))+'9.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'10.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'10.txt';
mite:=10
end
else if FileExists(ExtractFilePath(ParamStr(0))+'10.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'11.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'11.txt';
mite:=11
end
else if FileExists(ExtractFilePath(ParamStr(0))+'11.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'12.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'12.txt';
mite:=12
end
else if FileExists(ExtractFilePath(ParamStr(0))+'12.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'13.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'13.txt';
mite:=13
end
else if FileExists(ExtractFilePath(ParamStr(0))+'13.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'14.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'14.txt';
mite:=14
end
else if FileExists(ExtractFilePath(ParamStr(0))+'14.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'15.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'15.txt';
mite:=15
end
else if FileExists(ExtractFilePath(ParamStr(0))+'15.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'16.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'16.txt';
mite:=16
end
else if FileExists(ExtractFilePath(ParamStr(0))+'16.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'17.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'17.txt';
mite:=17
end
else if FileExists(ExtractFilePath(ParamStr(0))+'17.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'18.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'18.txt';
mite:=18
end
else if FileExists(ExtractFilePath(ParamStr(0))+'18.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'19.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'19.txt';
mite:=19
end
else if FileExists(ExtractFilePath(ParamStr(0))+'19.txt') and ( not FileExists(ExtractFilePath(ParamStr(0))+'20.txt'))
then
begin
FileName:=ExtractFilePath(ParamStr(0))+'20.txt';
mite:=20
end;
AssignFile(F,FileName); {将文件名与变量 F 关联}
ReWrite(F); {创建Txt文档并命名为 “FileName ” }
Closefile(F); {关闭文件 F}
Result:=mite;
End;
Function NewTxt(mite:integer):integer;
Var
F : Textfile; {定义 F 为 Textfile}
FileName:string;
i:integer;
FilePath:string;
Begin
FilePath:=ExtractFilePath(ParamStr(0));
for i:=1 to 20 do
begin
FileName:=FilePath+IntToStr(i)+'.txt';
if not FileExists(FileName) then begin
FileName:=FilePath+IntToStr(i)+'.txt';
mite:=i;
Break;
end;
end;
AssignFile(F,FileName); {将文件名与变量 F 关联}
ReWrite(F); {创建Txt文档并命名为 “FileName ” }
Closefile(F); {关闭文件 F}
Result:=mite;
End;