const
br=#13#10;
var
last_check:byte;
function explode(source:string; const delimiter:string):array of string;
var position,dellength,reslength:integer;
begin
dellength:=length(delimiter);
source:=source+delimiter;
repeat
position:=pos(delimiter,source);
setarraylength(result,reslength+1);
result[reslength]:=copy(source,1,position-1);
reslength:=reslength+1;
delete(source,1,position+dellength-1);
until (position=0);
setarraylength(result,reslength-1);
end;
function check_file_length(name:string):integer;
var tmp:array of string;
begin
if not fileexists(name)
then begin
writeln('File does not exist.');
result:=0;
exit;
end else begin
tmp := explode(readfile(name),br);
result := getarraylength(tmp);
end;
end;
procedure do_check();
begin
if check_file_length('remote.txt') > 98 then begin
writefile('remote.txt','127.0.0.1');
writeln('RemoteDebug -> cleaned Remote.txt');
end;
end;
procedure apponidle(ticks:integer);
var today:byte;
begin
if ticks mod (60 * 60 * 60 * 24) = 0 then begin
today := strtoint(formatdate('d'));
if (last_check = 0)
or (today > last_check)
or ((today = 1) and (last_check > 27)) then begin
last_check := today;
do_check();
end;
end;
end;
procedure activateserver();
begin
last_check := strtoint(formatdate('d'));
do_check();
end;
The script will check 'remote.txt' every day and overwrite it with '127.0.0.1' if the file surpasses a length of 98 lines.