Re: Informix 4GL and C retquote function
Posted in 1991
Path: emory!wuarchive!usc!orion.oac.uci.edu!ucivax!ucla-cs!ucla-mic!agsm!ggordon From: ggordon@agsm.ucla.edu (Glen Gordon) Newsgroups: comp.databases Message-ID: <ggordon.678415904@uclagsm> Date: 2 Jul 91 00:58:22 GMT References: <1991Jun30.164111.21858@dircon.co.uk> Nntp-Posting-Host: risc.agsm.ucla.edu uaa1006@dircon.co.uk (Peter Miles) writes: >I'm having difficulties with the retquote function, when I use >it to return strings from a C program to an Informix 4GL program. >It works fine when I use it to return a string, but does not >work when I try to return a NULL string. >How should I return a NULL string to the 4GL? Using the following: > retquote(NULL); > retquote(""); > retquote((char *)'\\0'); > retquote('\\0'); >all cause an 'L' character to returned to the 4GL. >My 4GL uses a: LET retstr=func(abc) in the .4gl file and >the C function 'func'should return either a string or a NULL. The key is to use the undocumented snullquote function to set a character string to NULL. The following stupid little C example expects to be called from 4gl, and passed a character string as a parameter. If the first character of this string is blank, the function returns NULL, otherwise it returns a copy of the string. (Not very useful, but it gets the point across.) I deduced this from looking at the c translation of a 4gl function which initialized a local variable to NULL and then returned that variable. int testfunc() { char buffer[81]; popquote(buffer,81); if (buffer[0] == ' ') snullquote(buffer,sizeof(buffer)); retquote(buffer); return 1; } -- Glen Gordon | Internet: ggordon@agsm.ucla.edu Computing Services | Bitnet : ggordon@uclagsm.bitnet Anderson Graduate School of Management | AT&Tnet : (213) 206-6590 University of California, Los Angeles | Fax : (213) 206-2002