🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3116

ISO I/O question

#3116
From: Graham Stark
Date: Wed, 03 Jan 1996 16:35
59 lines
2156 bytes
Happy new year ot you all.

I wonder if I could pick all your brains on a wee problem I'm having converting some
code from Topspeed modula-2 to ISO standard M2 (using the GPM compiler for OS/2 EMX).

We have the following little TopSpeed function:

PROCEDURE EscapeHit() : BOOLEAN;
BEGIN
    RETURN IO.KeyPressed() AND (IO.RdKey() = Escape);
END EscapeHit;

This allows you to write things like:

REPEAT
  I := I + 1
  .....
UNTIL (I > 10000) OR EscapeHit();

This keeps looping until you actually hit esc. (it doesn't
wait at the bottom for a key to be pressed).

The question is: can you do something similar using only the
ISO I/O libraries. I thought that a function based on Look()
might do it:

PROCEDURE EscapeHit()
VAR OK:BOOLEAN;
    VAR Ch:CHAR;
    Res : IOConsts.ReadResults;
BEGIN
  IOChan.Look( StdChans.InChan() , Ch , Res ); 
  OK := (Res = IOConsts.allRight);
  RETURN OK AND (Ch = Escape);
END EscapeHit;

But this causes the program to wait at the end of the loop until a key is
pressed (at least using the GPM implementation, which I'm sure is correct).
On the other hand, if you do hit Escape it does indeed exit the loop.

Can anyone tell me what I should be doing here?

More generally, is there anywhere a tutorial guide to ISO M2, especially 
the libraries? 

As it is,I've had to work out what the libraries do from the comments 
in the DEF files and by trial and error. The standards document itself doesn't
sound like a bundle of laughs.

many thanks

Graham Stark


*******************************************************************
 The Institute for Fiscal Studies World Wide Web Server:
  http://www1.ifs.org.uk/
*******************************************************************
Technical Details
Message-ID: <1996Jan3.163557.31445@ucl.ac.uk>
Path: arc1-ca.pugleaf.net!bcc.ac.uk!news

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2
Path: arc1-ca.pugleaf.net!bcc.ac.uk!news
From: gstark@ifs.org.uk  (Graham Stark)
Subject: ISO I/O question
Sender: news@ucl.ac.uk (Usenet News System)
Message-ID: <1996Jan3.163557.31445@ucl.ac.uk>
Date: Wed, 3 Jan 1996 16:35:57 GMT
Reply-To: gstark@ifs.org.uk  (Graham Stark)
Organization: The Institute for Fiscal Studies
X-Newsreader: IBM NewsReader/2 v1.02