Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!CSVAX.UCD.HEA.IRL!TWADE From: TWADE@CSVAX.UCD.HEA.IRL.UUCP Newsgroups: mod.computers.vax Subject: Reading Single characters at a time. Message-ID: <8703021858.AA17158@ucbvax.Berkeley.EDU> Date: Mon, 2-Mar-87 13:59:01 EST Article-I.D.: ucbvax.8703021858.AA17158 Posted: Mon Mar 2 13:59:01 1987 Date-Received: Tue, 3-Mar-87 22:30:47 EST Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 65 Approved: info-vax@sri-kl.arpa A couple of people mentioned that they needed to do single-character I/O without waiting for carriage return. Here is a small routine to do this. status = READ_KEY (ch_code) will read a single character from SYS$COMMAND (including DEL, CTRL/X and CTRL/U characters) without echoing and without waiting for CR. 'Status' is the return status from the $QIO call (low order bit set for success, so your HL language treats it as boolean TRUE for success). 'Ch_code' is the address of a character which will receive the ASCII code of the character entered (so C calls passes this parameter using the '&' operator I think). I've tested it with a FORTRAN calling program. Usual disclaimer: I take no responsibility for anything whatsoever. ---- File READKEY.MAR -----------X Cut Here X--------------------------- .Title READ_CHAR_FROM_TERMINAL ; Routine to read characters from terminal. ; Tom Wade, UCD computer science twade@csvax.ucd.hea.irl Char: .Byte 0 Iosb: .Quad 0 Ttchan: .Long 0 Tty: .Ascid "SYS$COMMAND" .Entry READ_KEY M <> ; Read a character from the keyboard without echo or Tstl ttchan ; channel open ? Bneq get_key ; yes. Bsbw OPEN_CHAN Get_key: $QIOW_S - chan = ttchan, - func = #, - iosb = iosb, - p1 = char, - p2 = #1 Blbc R0, exit Movzwl iosb, R0 Blbc R0, exit Movl #SS$_NORMAL, R0 Movzbl char, @4(AP) Exit: Ret OPEN_CHAN: $ASSIGN_S - ; open a channel to TTY chan = ttchan, - devnam = tty Rsb .End ------------ End of file READKEY.MAR -----X Cut Here X------------------ ------------------------------------------------------------------------- Tom Wade Internet: twade@csvax.ucd.hea.irl Systems Programmer Ean: twade@csvax.ucd.irl Dept Computer Science PSI: PSI%27243154000721::TWADE University College Dublin Telex: (0500) 91196 UCD EI Ireland. Voice: +353-1-693244 Ext 2472 -------------------------------------------------------------------------