if your algo of searching value is very long, you can insert this in your code:
if ((GetTickCount() - openfiletime) >= 5000) than
Break; (or Exit;)
Main Topics
Browse All TopicsHi,
I want to know the best way to for example read a file constantly looking for a value and if the value is not present in 5 seconds then abort.
I have seen something using GetTickCount but i am not sure how to use it.
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi!
You dont say what kind of file and the value expected so... I assume that is a text file and the value to look for is a string.
Is this is not true, simply change the function ValueIsPresentInFile as you wish...
procedure TForm1.Button1Click(Sender
function ValueIsPresentInFile(FileN
var
TheFile: TStringList;
begin
Result:=FALSE;
if NOT FileExists(Filename) then Exit;
TheFile:=TStringList.Creat
try
//Load The File
TheFile.LoadFromFile(Filen
//Test if value exists into:
Result:=( Pos(TheValue,TheFile.Text)
finally
TheFile.Free;
end;
end;
var
StartTime : TTime;
IsPresent : boolean;
begin
//Get the Actual time:
StartTime:=Time;
repeat
IsPresent:=ValueIsPresentI
until IsPresent or ( (Time-StartTime) > StrToTime('00:00:05') );
if IsPresent then ShowMessage('The value is in the file')
else ShowMessage('Sorry, the file does not contain the value for 5 secs...');
end;
Business Accounts
Answer for Membership
by: -Thespian-Posted on 2005-08-25 at 02:15:59ID: 14750152
U are right about GetTickCount. You ran use such algo (openfiletime: integer):
open file;
openfiletime := GetTickCount();
while (not eof(myfile))
begin
if ((GetTickCount() - openfiletime) >= 5000) than
Break;
searching value.....
end;
close file;