Re: Using printf() in a 4gl program w/C
Posted in 1992
Path: emory!samsung!uunet!gossip.pyramid.com!pyramid!infmx!girard From: girard@informix.com (J. Girard Chandler) Newsgroups: comp.databases.informix Message-ID: <1992Jan30.195356.15897@informix.com> Date: 30 Jan 92 19:53:56 GMT References: <1992Jan28.215456.3789@kodak.kodak.com> <1992Jan30.000533.25067@cbnewsm.att.com> Sender: news@informix.com (Usenet News) Organization: Informix Software, Inc. In article <1992Jan30.000533.25067@cbnewsm.att.com> jonesie@cbnewsm.att.com (The Bohemian Welshman) writes: >In article <1992Jan28.215456.3789@kodak.kodak.com> (Mitch Amiano) writes: >>This may be a simple question, but are there any known problems >>calling a C function which uses printf() from a 4gl program ? > >> The output looks like this: >> >> First status message. >> Next status message. >> Next message... ... >#include <termio.h> >void fix_io() >{ > struct termio arg_struct; > > if ( ioctl(1,TCGETA,&arg_struct) < 0) > fprintf(stderr,"TCGETA error\\n"); > arg_struct.c_oflag = arg_struct.c_oflag | ONLCR; > if ( ioctl(1,TCSETA,&arg_struct) < 0) > fprintf(stderr,"TCSETA error\\n"); >} An alternative solution can be found buried on page S-211 of the 4.1 4GL Supplement: int fgl_exitfm(); "... This macro resets the terminal for character mode ..." This library call also has the additional side-effect of re-positioning the cursor to the bottom of the screen. However, it is safe to mix this call with 4GL display statements. For example, you can use this function to do terminal I/O from a C function called from within a MENU statement - and have the MENU behave correctly when you return. This function was introduced in version 4.1 as part of a suite of library calls to allow one to call 4GL (interpreted or compiled) functions from C - but it may be used independently. -Girard Chandler (Informix 4GL development)