home *** CD-ROM | disk | FTP | other *** search
-
- PROGRAM getreal; {Or, how do you bullet-proof numerical entries?}
- {One choice is don't, then get I/O crashes.....}
- {Contributed by: Count Zero Interrupt & }
- { 6/87 General Max von Birdface (Ret)}
-
- VAR
- number : REAL;
- code : INTEGER;
-
- PROCEDURE getreal1 (VAR number:REAL; VAR code:INTEGER);
-
- { Looks at entry and assigns codes for appropriate & other types }
-
- VAR
- entry : STRING[30];
-
- BEGIN
- Read(entry);
- Val(entry,number,code);
- CASE Length(entry) OF
- 0 : code := -2;
- 1 :
- IF code > 0 THEN
- BEGIN
- code := -1;
- END
- END;
- END;
-
- { Mainline for Procedure }
-
- BEGIN
- ClrScr;
- GotoXY(1,23);
- Write('Enter a number: ');
-
- REPEAT
- getreal1(number,code);
- IF (code <> 0) THEN
- BEGIN
- Sound(100);
- Delay(500);
- NoSound;
- GotoXY(1,23);
- ClrEol;
- GotoXY(20,23);
- Write('Please!! Just Enter NUMBERS!! : ');
- END
- UNTIL (code = 0);
- GotoXY(1,15);
- Write('The number is: ',number:4:1);
- END.