mac@harris.cis.ksu.edu (Myron A. Calhoun) (10/25/90)
Here is an EASY solution to the question: >I would like to know how to read 1 character from a fortran program >on unix without having to type a carriage return after the character. SUBROUTINE GET1KY (Char) c**** Get a single character without the necessity of a carriage return. CHARACTER Char*1 INTEGER getc, Status c---- Set TTY to return characters immediately and NO (-) echoed input c (Read "man 2 intro" for an introduction to making system calls) CALL system ("stty cbreak -echo") c---- Read a character (I ignore the status) c (Read "man 3f getc", "man 3s getc", and "man 3f perror" for c additional information) Status = getc (Char) c---- Reset TTY to 'normal': NO (-) immediate characters, echoed input CALL system ("stty -cbreak echo") END The system I use this on is a Harris HCX-9 running CX/UX 4.1. I compile everything using "make"; here are the pertinent lines from a Makefile. Note that my Makefile does NOT mention either "getc" or "system". (Incidentally, "blkdta.f" is a BLOCK DATA module, which ties in another recent group thread!) speech : .add.o .bkscan.o .blkdta.o .change.o .delete.o .find.o\ .get1ky.o .getcmd.o .getwrd.o [and about 15 more modules...] f77 -ouwC sp .speech.o .*.o chmod 700 sp .get1ky.o : get1ky.f f77 -cuwC get1ky.f /bin/mv -f get1ky.o .get1ky.o .blkdta.o : common.f blkdta.f f77 -cuwC blkdta.f /bin/mv -f blkdta.o .blkdta.o .speech.o : common.f speech.f f77 -cuwC speech.f /bin/mv -f speech.o .speech.o [many, many more lines of Makefile deleted for brevity] --Myron. -- # Myron A. Calhoun, Ph.D. E.E.; Associate Professor (913) 539-4448 home # INTERNET: mac@harris.cis.ksu.edu (129.130.10.2) 532-6350 work # UUCP: ...{rutgers, texbell}!ksuvax1!harry!mac 532-7353 fax # AT&T Mail: attmail!ksuvax1!mac