All,
Is there any kind of time out function that I can use as one of the parameters to terminate a While/Do loop?
I have the below code example (not perfect syntax for this post) that reads input from a bar code scanner. Most scanners are like a keyboard in that they terminate the scan with a <CR>, but not all scanners. I would like to terminate the loop below based on either the criteria that the <CR> was found or x milliseconds have passed.
I did a search and there seem to be some timer functions, but I could not find any code examples and I am unsure how to implement them.
Program ReadScanner
instring:='';
InitKeyBoard;
Writeln;
Writeln('----------------Scan now or push ESC for main menu.--------------------');
while H<>CR do OR TIMEOUT //terminate with a CR or a TimeOut. Is there anything I can use for TIMEOUT?
begin
K:=GetKeyEvent;
K:=TranslateKeyEvent(K);
if K<>ESC_CODE then
Begin
H:=GetKeyEventChar(k);
abc:=GetKeyEventCode(k);
ch:=KeyEventToString(K);
if (GetKeyEventChar(K)<>CR) then instring:=instring+chr(abc);
end;
DoneKeyBoard;