Re: DBDATE - Inside Informix 4gl
Posted in 1998
Jonathan Leffler wrote: > > draikar@my-dejanews.com wrote: > > Could you please tell me how to overwrite the date format > > (which had been set in the environment variable DBDATE) > > inside the Informix 4gl program? > > It depends on the context. Any time you explicitly convert a > DATE into a string, you can use a USING "dd mmm yyyy" or similar > format to obtain the format you choose, thus overriding the value > of DBDATE. During INPUT etc, when a string is converted to a date, the > conversion is fairly flexible anyway, and really only uses DBDATE > to determine the order of the components. > > > Work Environment: > > > > Informix-4gl Ver 7.20 UD1 > > OS: Sun-Solaris 2.6 > > > > Thanks > > > > -Dinesh > > > > P.S. I have used the "fgl_getenv()" to get an environment variable, > > but I wanted to know how to set an environment inside the 4gl > > program. > > Ah. Setting an environment variable inside a 4GL program is tricky > on at least three counts. > > * The standard function for doing the job is putenv(), but it isn't > all that standard -- ISO C doesn't standardize it; neither does > POSIX. The Open Group does in Unix 98, I think. > * Using putenv() correctly is more difficult than you'd think. Most > of the easy ways of doing it in I4GL lead to corruption of the > environment in some circumstances. > * It isn't clear whether you can change DBDATE or other environment > variables after they've been used and expect the change to be noted. > With some variables, you can; with others, you can't -- they are > 'gated' and read once and that value first read is used thereafter. > > There is code in the I4GL CGI kit on the IIUG web site > (http://www.iiug.org) which does implement a setenv() C function, > along with getenv() and putenv(), and this is usable from I4GL because > it avoids the easy mistakes rather carefully. Yes, I wrote it. > > -- > Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) > Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN > #include <disclaimer.h> It would be interesting to know what you want to achieve with this changing of DBDATE. As changing it is not guaranteed to affect the current process in a predictable way and there are alternatives anyway, the only sensible aim would be to change it for a child process. (You can't change it for a parent.) Given that, you can do this: RUN "DBDATE=DMY4 myprog.4ge" (Assuming RUN uses the shell to do its work - not tested.) -- Peter Lancashire Information Systems Specialist, Bayer plc Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK Tel: +44-1635-562258, Fax: +44-1635-562281 --- If all else fails, read the instructions AND the release notes. All opinions are my own and not those of Bayer plc. My Internet plumbing does not allow me to mail and post news together. Sorry. --- Join Infuse, the UK Informix User Group at http://www.infuse.org.uk/