Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!jason From: jason@comp.lancs.ac.uk (Mr.J.P.Kitchen) Newsgroups: comp.lang.ada Subject: Non line-buffered input Message-ID: <1115@dcl-vitus.comp.lancs.ac.uk> Date: 3 Dec 90 11:27:16 GMT Reply-To: jason@comp.lancs.ac.uk (Mr.J.P.Kitchen) Distribution: comp.lang.ada Organization: Department of Computing at Lancaster University, UK. Lines: 65 Arne - I lost your Email address - but I'm posting here because it should have more general interest. >> >> Newsgroups: comp.lang.ada >> Organization: Department of Computing at Lancaster University, UK. >> >> Text_io is line buffered. The only way around this is to write your own >> single character I/O routines in another language (e.g. 'C') and pragma >> interface it to your Ada programs. >> >That sounds like a practicable solution. The problem is, I don't know >anything about pragma. Could you possibly tell me how touse it ?? It depends on what system you're using and (unfortunately) which Ada compiler. On our system which is running under UNIX version xxx and using the York Ada Compiler, a sample program may be as follows:- package MY_IO is pragma LIBNAME("get_charac"); function GET_CHARAC return CHARACTER; end MY_IO; with MY_IO, TEXT_IO; use TEXT_IO, MY_IO; procedure TEST is CH: CHARACTER; begin loop PUT("Press a key (don't press return after it): "); CH:= GET_CHARAC; NEW_LINE; PUT("The key was "); PUT(CH); NEW_LINE(2); end loop; end TEST; Note: the PRAGMA LIBNAME would be replaced by PRAGMA INTERFACE(C,GET_CHARAC) in most versions of Ada. You will also need a 'C' program along the following lines in another file:- #include char get_charac() { char ch; system("stty cbreak"); /* half cooked mode */ ch=getc(stdin); system("stty -cbreak"); /* back to normal */ return ch; } To compile this with the York Ada compiler, I used the following command:- Ac -M test.A get_charac.c -M tells the compiler that a main unit is being submitted. Hope this is useful to you. --Jason Brought to you by Super Global Mega Corp .com