home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.modula3
- Path: sparky!uunet!usc!cs.utexas.edu!sun-barr!decwrl!src.dec.com!src.dec.com!mjordan
- From: mjordan@src.dec.com (Mick Jordan)
- Subject: Re: Trouble with stdin on RS/6000
- Message-ID: <1993Jan13.040547.27180@src.dec.com>
- Sender: news@src.dec.com (News)
- Organization: DEC Systems Research Center
- References: <1993Jan12.172641.40124@slate.mines.colorado.edu>
- Date: Wed, 13 Jan 93 04:05:47 GMT
- Lines: 42
-
- In article <1993Jan12.172641.40124@slate.mines.colorado.edu>, lpratt@slate.mines.colorado.edu (Lorien Pratt) writes:
- |> 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.
-
- There is nothing wrong with program and it works on a DECstation, so I would
- suspect something is amiss in the RS6000 runtime system. Lets hope an
- RS6000 M3 wizard can help.
-
- |> I'd appreciate any pointers for how tell modula-3 to generate code to
- |> expect stdin from the terminal. Thanks!
- |>
-
- For the record, the compiler knows nothing about the input/output system.
- Stdio, Rd and Wr are just modules like any other. The Stdio module
- arranges, as part of its initialisation code, to connect stdin/stdout/stderr
- to the Unix file descriptors of the same name.
-
- Two improvements I would suggest to the program:
-
- 1. Stdio.stdout is buffered and, perhaps to your suprise, the buffer is
- not flushed by the '\n' character. You need to call "Wr.Flush(Stdio.stdout)"
- either after each output or before any input requests.
-
- 2. I find the concatenation of text literals and text values rather unreadable.
- You can rewrite:
-
- Write("The sum of " & Fmt.Int(n1) & " And " & Fmt.Int(n2) & " is " &
- Fmt.Int (n1 + n2) & ".\n");
-
- as:
-
- Write(Fmt.F("The sum of %s and %s is %s.\n", Fmt.Int(n1), Fmt.Int(n2),
- Fmt.Int (n1 + n2)));
-
- which is about as close to "printf" as you can get without wiring
- input/output into the compiler.
-
- Mick Jordan
-
-