jason@comp.lancs.ac.uk (Mr.J.P.Kitchen) (12/03/90)
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 <stdio.h> 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
mciver@kalkan.colorado.edu (William McIver Jr.) (12/14/90)
In article <1115@dcl-vitus.comp.lancs.ac.uk> jason@comp.lancs.ac.uk (Mr.J.P.Kitchen) writes: >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:- > [stuff deleted] > >--Jason FYI: For those using DEC Ada, it is not necessary to write such a routine in another language. One can use the VAX/VMS System Services Package which has the QIO & QIOW routines in an Ada Package interface. I've done this before, unfortunately the source is not immediately available. It is not difficult though. WJM -- -------------------------------------------------------------------- William J. McIver, Jr. mciver@tigger.colorado.edu Department of Computer Science, University of Colorado @ Boulder --------------------------------------------------------------------