Re: Globals file in SE/4GL v4.00
Posted in 1995
>From: tech@compsys.demon.co.uk ("tech) >Date: Tue, 14 Mar 1995 10:16:27 +0000 >X-Informix-List-Id: <news.12173> > >Has anybody managed to get the GLOBALS "filename" command to work correctly >in Informix 4GL or RDS v4.00 ? Yes. >When I use the RDS compiler, the globals file is read ok, but when you try >to run the resultant 4gi, you get variable not defined error messages. That's because when you use the notation: GLOBALS "globals.4gl" in a file program.4gl, you are not defining any variables; you are simply declaring them. This is C terminology. You have to compile the file globals.4gl as well as program.4gl, and then link the two together -- which means concatenating the two .4go files into a .4gi file in the p-code system. >If you try to C4GL compile the program, you are presented with >unreferenced symbol error messages. In the c-code system, you have to link both object files together to produce a .4ge file. >The only way I can find around the problem is to have a GLOBALS DEFINE >section at the start of every program and list every variable that you >require. This will actually work on most Unix systems, but is not guaranteed to do so by the ANSI C standard. Further, if you are using global variables of DATETIME or INTERVAL type (or records containing DATETIME or INTERVAL elements) and you are using version 6.00 or 6.01 I4GL, then you will run into link problems as the variable will be multiply defined. There was an extensive discussion of this about a year ago in c.d.i under the heading 'Are you cheating with GLOBALS?'. >This is very time consuming when you are using lots of programs >which require the same variables - especially if you change the list of >global variables in any way! The next release of I4GL (4.14/6.02) will help with some of these problems by allowing more than one GLOBALS section in the heading (preamble) of a source file. That will allow you to do: GLOBALS "globals1.4gl" GLOBALS "globals2.4gl" GLOBALS DEFINE ... END GLOBALS GLOBALS "globals3.4gl" etc, with arbitrary interleaving of GLOBALS references (GLOBALS 'file.4gl') and GLOBALS definitions (GLOBALS DEFINE ... END GLOBALS), and module variable definitions (DEFINE not inside GLOBALS/END GLOBALS). You can have multiple DATABASE statements in there as well, provided that all the database names are the same. The acceptable contents of the globals files themselves has not changed -- they can only consist of an optional DATABASE statement followed by a single GLOBALS/END GLOBALS block, though there can be multiple DEFINE statements inside that one block. You will still need to compile each of the GLOBALS files independently and link all the resulting object files together to produce the executable or interpretable. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>