eNarc
asked on
Try Until Error Then Stop Function
Hi Experts
I need some code to for this
function copyfiles(files:string):st ring;
var
i:Integer;
begin
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db' ), pchar(files+inttostr(i)+'. db'), False);
end;
end
how can I do it so that when there is a error it will stop the process.
I need some code to for this
function copyfiles(files:string):st
var
i:Integer;
begin
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db'
end;
end
how can I do it so that when there is a error it will stop the process.
This might do the trick:
function copyfiles(files:string):st ring;
var
i:Integer;
try
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db' ), pchar(files+inttostr(i)+'. db'), False);
except
abort;
end;
end;
end
function copyfiles(files:string):st
var
i:Integer;
try
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db'
except
abort;
end;
end;
end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or a Message on error then abort:
function copyfiles(files:string):st ring;
var
i:Integer;
begin
try
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db' ), pchar(files+inttostr(i)+'. db'), False);
end;
except
on E : Exception do
begin
ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
abort;
end;
end;
end;
function copyfiles(files:string):st
var
i:Integer;
begin
try
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db'
end;
except
on E : Exception do
begin
ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
abort;
end;
end;
end;
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
function copyfiles(files:string):st
var
i:Integer;
begin
try
for i:=0 to 100 do begin
CopyFile(pchar(files+'.db'
except
//errorhandling
end;
end;
end