Using Pascal’s traditional
read procedures you will need use a
string variable as Josh already suggested. In FPC it is furthermore possible to temporarily disable
input checking:
program proceduralInputErrorHandling(input, output, stdErr);
var
i: integer;
begin
repeat
begin
write('Enter an integer: ');
{$push}
{$IOChecks off}
readLn(i)
{$pop}
end
until IOResult = 0;
end.
The
IOResult function returns
106 if the user entered a non-integer.
[…] shouldnt enter a number on string code […]
In this case you will need to attempt a conversion to
real. If it
succeeds you will need to prompt again.
It is, however, not possible
preventing the user from typing certain keys. If you want
immediate feedback, your
program has to filter keystrokes, for example with the aide of the
keyboard unit like jcm********* suggested.
[…]until TryStrToFloat(avalue)=true;
[…]
until TryStrToFloat(avalue)=false;
Please don’t promote
= true checks. It’s already terrible enough that occasionally beginners write that.