home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!asuvax!ncar!vexcel!copper!slate!lpratt
- From: lpratt@slate.mines.colorado.edu (Lorien Pratt)
- Newsgroups: comp.lang.modula3
- Subject: Trouble with stdin on RS/6000
- Message-ID: <1993Jan12.172641.40124@slate.mines.colorado.edu>
- Date: 12 Jan 93 17:26:41 GMT
- Sender: lpratt@slate.mines.colorado.edu (Lorien Pratt)
- Organization: Colorado School of Mines
- Lines: 70
-
- Hi,
- I'm trying to write a simple modula-3 program that takes input from the
- terminal. Unfortunately, the program doesn't pause to wait for input from
- stdin; instead it receives an end of file indication. If I echo the input
- to the program, however, it does work.
- Specifically, I've typed in Example 1-8 in Harbison (page 12). It looks
- like this:
- ----
- MODULE WriteSum EXPORTS Main;
- IMPORT Wr, Rd, Fmt, Scan, Stdio;
-
- PROCEDURE Read(): INTEGER =
- BEGIN
- RETURN Scan.Int( Rd.GetLine(Stdio.stdin));
- END Read;
-
- PROCEDURE Write(t:TEXT) =
- BEGIN
- Wr.PutText(Stdio.stdout, t);
- END Write;
-
- VAR n1, n2: INTEGER;
- BEGIN
- Write("Please type two numbers on separate lines:\n");
- n1 := Read();
- n2 := Read();
- Write("The sum of " & Fmt.Int(n1) & " And " & Fmt.Int(n2) & " is " &
- Fmt.Int (M^n1 + n2) & ".\n");
- END WriteSum.
-
- -----
- Now, if I compile this and try to run it, I get the following error
- message:
- ----
- a.out
- ****************** EXCEPTION HANDLER STACK *********************
- 0x2ff7fa98 TRY-FINALLY proc = 0x2006daac frame = 0x2ff7fa8c
- 0x2ff7fb4c RAISES {}
- ****************************************************************
-
-
- ***
- *** runtime error:
- *** Exception "Rd.EndOfFile" not in RAISES list
- ***
-
- Please type two numbers on separate lines:
- Quit(coredump)
- ----
- But if I echo the proper input to the program, it works:
- ----
- echo "1
- 2" |a.out
- Please type two numbers on separate lines:
- The sum of 1 And 2 is 3.
- ----
-
- I'd appreciate any pointers for how tell modula-3 to generate code to
- expect stdin from the terminal. Thanks!
-
- --Lori
-
-
-
-
- --
- L. Y. Pratt Dept. of Math and Computer Science
- lpratt@franklinite.mines.colorado.edu Colorado School of Mines
- (303) 273-3878 (work) 402 Stratton
- (303) 278-4552 (home) Golden, CO 80401, USA
-