Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!trac2000!das From: das@trac2000.ueci.com (David Snyder) Newsgroups: comp.databases Subject: Re: Environment variables in Informix Message-ID: <1025@trac2000.ueci.com> Date: 25 May 91 02:54:02 GMT References: <1991May23.220608.14498@dircon.co.uk> Organization: UE&C - Catalytic in Philadelphia, PA Lines: 77 In article <1991May23.220608.14498@dircon.co.uk>, uaa1006@dircon.co.uk (Peter Miles) writes: > > I've got Informix 4GL (and RDS) version 2.10.03F. > > Can anyone tell me whether it's possible to read (and write) > an environment variable from within a 4GL program? > You sure can! Here are the functions that we use... Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip /* usr_funcs.c * This module contains 'C' functions that are used by Informix-4GL * at run-time. They should work with both RAPID and COMPILED 4GL. */ /******************************************************************************* * This function allows the getting of an environment variable from 4GL. * *******************************************************************************/ dbgetenv(arg) int arg; { char s[513], *getenv(); popquote(s, sizeof(s)); rtrim(s); retquote(getenv(s)); return(1); } /******************************************************************************* * This function allows the setting of an environment variable from 4GL. * *******************************************************************************/ dbputenv(arg) int arg; { static char s[513]; popquote(s, sizeof(s)); rtrim(s); retint(putenv(s)); return(1); } #include #include /******************************************************************************* * This function trims non-printing characters (including space) from the right * * side of a character pointer. * *******************************************************************************/ rtrim(s) char *s; { int i; for (i = strlen(s) - 1; i >= 0; i--) if (!isgraph(s[i]) || !isascii(s[i])) s[i] = '\0'; else break; } Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip DAS -- David A. Snyder @ UE&C - Catalytic in Philadelphia, PA UUCP: ..!uunet!trac2000!das INTERNET: das@trac2000.ueci.com