[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gm2] Confusing issue w/ Read(ch)
From: |
rob solomon |
Subject: |
[Gm2] Confusing issue w/ Read(ch) |
Date: |
Thu, 10 Oct 2013 22:57:16 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
Consider this sample program:
MODULE TestStrIOg;
(*
REVISION HISTORY
----------------
10 Oct 13 -- Testing terminal read char if it does what it should
under gm2.
*)
IMPORT StrIO, StdIO, NumberIO, IO;
VAR
CH : CHAR;
BEGIN
LOOP
StrIO.WriteString(' Enter a single character for StdIO: ');
StdIO.Read(CH);
StdIO.Write(CH);
StrIO.WriteLn;
StrIO.WriteString(' decimal value of entered char is: ');
NumberIO.WriteCard(ORD(CH),0);
StrIO.WriteLn;
IF CAP(CH) = 'Q' THEN EXIT; END(*IF*);
StrIO.WriteString(' Enter a single character for IO: ');
IO.Read(CH);
IO.Write(CH);
StrIO.WriteLn;
StrIO.WriteString(' decimal value of entered char is: ');
NumberIO.WriteCard(ORD(CH),0);
StrIO.WriteLn;
IF CAP(CH) = 'Q' THEN EXIT; END(*IF*);
END(*LOOP*);
END TestStrIOg.
I do something like this under StonyBrook Modula-2, and the Read(CH)
call waits for a single character and then continues without waiting for
<enter>.
This test program run with gm2 waits for <enter> and then the second
call to Read(CH) will always return this <enter> as decimal value 10.
Does not matter if I use StdIO.Read or IO.Read here, in any order, I get
the same result.
I would like the program to continue after a single character is hit
without waiting for <enter>.
How do I do that?
--rob
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gm2] Confusing issue w/ Read(ch),
rob solomon <=