Re: Set an environment variable from within a 4GL program?
Posted in 1995
>From: dshirazi@labyrnth.uhl.uiowa.edu (Dariush Shirazi) >Date: 27 Mar 1995 17:37:46 GMT >X-Informix-List-Id: <news.12465> >June Tong (junet@informix.com) wrote: >: Ajay Chitale <achit@rtsg.mot.com> wrote: >: >proberts@lynx.informix.com (Paul Roberts) writes: >: >|> Can I set an environment variable from within a 4GL program and have >: >|> it be `effective' in the subsequent running of the program? >: >All you can do is link your 4gl code with a 'c' routine which will set >: >your environment as per your needs. >: Maybe, but if you're planning on setting any environment variables that >: Informix uses, I'm pretty sure Informix reads them when you start up your >: application, so anything you change in the application will never be read. >: Try it and see -- it's the only way to be sure. >That is not true! I have a routine that sets DBPRINT within the 4gl >program and just before start report and it works fine. I've seen a number of comments on this thread of varying accuracy. Different environment variables are handled differently. * DBPRINT is checked when the report is started. * DBDATE is trapped when the first DATE operation occurs (roughly). Other variables are generally handled in one of these two ways. In 6.0 and above, the use of informix.rc files (see p4-4 in the Informix Guide to SQL Reference Version 6.0) makes the lookup of environment variables expensive so there are more operations which trap the value at the point where the first relevant operation occurs. Not all I4GL (or ISQL) code makes use of the informix.rc file -- a bug. So, the short answer to the original question is 'sometimes'. But the behaviour is undefined and therefore both unreliable and subject to change. The only reliable technique is to set the environment variable before running the program, and to use some technique not based on envirnonment variables if you must change things while the program is running. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>