Category : Pascal Source Code
Archive   : CLEMENT.ZIP
Filename : INPUT.INT

 
Output of file : INPUT.INT contained in archive : CLEMENT.ZIP

(*----------------------------------------------------------*)
(* Copyright (c) 1985, 1986 Namir Clement Shammas *)
(*----------------------------------------------------------*)

(*---------------------------------------- Read_Int ---------*)

PROCEDURE Read_Int(VAR I : INTEGER (* output *));
(* Procedure to correctly input an integer from the keyboard *)
CONST BEEP = ^G;

VAR Error_Code, PosX, PosY : INTEGER;
S : STRING[80];

BEGIN
PosX := WhereX;
PosY := WhereY;
READ(S);
Val(S, I, Error_Code);
WHILE Error_Code > 0 DO BEGIN
WRITE(BEEP);
GOTOXY(PosX, PosY); ClrEol;
READ(S);
Val(S, I, Error_Code)
END;
END; (* Read_Int *)

(*---------------------------------------- Read_Int_Limit ---------*)

PROCEDURE Read_Int_Limit(VAR I : INTEGER (* output *);
Low, High : INTEGER (* input *));
(* Procedure to correctly input a range of integers from the keyboard *)
CONST BEEP = ^G;

VAR Error_Code, PosX, PosY : INTEGER;
S : STRING[80];

BEGIN
PosX := WhereX;
PosY := WhereY;
READ(S);
Val(S, I, Error_Code);
WHILE (Error_Code > 0) OR
(I < Low) OR (I > High) DO BEGIN
WRITE(BEEP);
GOTOXY(PosX, PosY); ClrEol;
READ(S);
Val(S, I, Error_Code)
END;
END; (* Read_Int_Limit *)

(*---------------------------------------- Read_Real ---------*)

PROCEDURE Read_Real(VAR X : REAL (* output *));
(* Procedure to correctly input a real from the keyboard *)
CONST BEEP = ^G;

VAR Error_Code, PosX, PosY : INTEGER;
S : STRING[80];

BEGIN
PosX := WhereX;
PosY := WhereY;
READ(S);
Val(S, X, Error_Code);
WHILE Error_Code > 0 DO BEGIN
WRITE(BEEP);
GOTOXY(PosX, PosY); ClrEol;
READ(S);
Val(S, X, Error_Code)
END;
END; (* Read_Real *)

(*---------------------------------------- Read_Real_Limit ---------*)

PROCEDURE Read_Real_Limit(VAR X : REAL (* output *);
Low, High : REAL (* input *));
(* Procedure to correctly input a range of reals from the keyboard *)
CONST BEEP = ^G;

VAR Error_Code, PosX, PosY : INTEGER;
S : STRING[80];

BEGIN
PosX := WhereX;
PosY := WhereY;
READ(S);
Val(S, X, Error_Code);
WHILE (Error_Code > 0) OR
(X < Low) OR (X > High) DO BEGIN
WRITE(BEEP);
GOTOXY(PosX, PosY); ClrEol;
READ(S);
Val(S, X, Error_Code)
END;
END; (* Read_Real_Limit *)


(*-------------------------------------------------------------------*)