Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime!heyman.austin.ibm.com!jerry From: jerry@heyman.austin.ibm.com (Jerry Heyman) Newsgroups: comp.lang.fortran Subject: Re: INKEY routine for UNIX fortran (was: Read one keystroke with...) Message-ID: <5166@awdprime.UUCP> Date: 7 Feb 91 15:29:34 GMT References: <1991Feb4.195630.6570@math.ufl.edu> Sender: news@awdprime.UUCP Organization: IBM Austin, TX Lines: 29 In article <1991Feb4.195630.6570@math.ufl.edu> wang@math.ufl.edu writes: >I saw someone posted an article asking for a routine which reads a >keystroke without a carriage return for MS-fortran. I am asking a >similar routine for UNIX fortran. The routine I want is much like a >BASIC's "INKEY" routine which returns the ASCII code (an integer) of a >character input from the keyboard without a carriage return. It's >shame that such an important routine does not come with any of FORTRAN >compiler.... The best way to handle that in Unix is to make a call to the 'stty ()' function that changes the mode of the terminal input. By default most (if not all) terminal input is buffered and is known as 'cooked'. What you want is to change the terminals actions to 'raw' - ie when a keystroke is made, you want to see it - NOT wait for a carriage return to be pressed. This is callable from C as I have several programs that make use of this, and I would assume that the same function is available to the Fortran compiler as a direct call to the operating system. Word of caution, once you turn on 'raw', all keyboard i/o will be in that mode until you reset it to 'cooked'. jerry -- Jerry Heyman IBM T-R: jerry@heyman.austin.ibm.com AWD Tools Development VNET : HEYMAN at AUSVMQ AWD Austin T/L : 793-3962 *** All opinions expressed are exactly that - my opinions and NOT IBM's