Re: GLOBALS statement everywhere
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Jobs, Consulting & Announcements
At the risk of Jonathan L correcting me (which he does only when I'm WRONG), you need the GLOBALS statement in any module that makes reference to any of the variables defined in the GLOBALS function. Otherwise it's not needed. The DATABASE statement is used at compile time if you have any DEFINE statements (in the GLOBALS function or otherwise) that use LIKE syntax ("DEFINE r_table RECORD LIKE table.*"). It is used at run time to open the database (in this context, it can be within a function as well as at the top of a module). So use the DATABASE statement in the module with the MAIN for both reasons, and elsewhere for the first. So (here's where johnl might get me; I haven't done this in awhile) if your globals module (a module containing only the GLOBALS function and no others) has a DATABASE statement in it, and your GLOBALS statement is at the top of the module, there's no need for another DATABASE statement. Note there's a difference between the GLOBALS function: (GLOBALS DEFINE ... END GLOBALS) and the GLOBALS statement: (GLOBALS "/full/path/name.4gl") In article <35c1946b.689599964@news.globalnet.co.uk>, xxx@xxx.xxx wrote: > Hi, > > I'm in the processing of revamping some code and have spotted what I > think is superflous use of the GLOBALS statement. > > A typical example would be as follows: > > a.4gl would look like this: > --------------------------------------- > DATABASE dbname > GLOBALS "/pathname/global.4gl" > DEFINE variable1 CHAR(20) > END DEFINE > MAIN > blah > END MAIN > FUNCTION func() > END FUNCTION > > b.4gl would look like this: > --------------------------------------- > DATABASE dbname > GLOBALS "/pathname/global.4gl" > FUNCTION func2() > END FUNCTION > > c.4gl would have the same structure as b.4gl > > As we are running RDS we compile the programs like this: > > fglpc a.4gl > fglpc b.4gl > fglpc c.4gl > > And finish off with: cat a.4go b.4go c.4go > newprog.4gi > > The question is: are the GLOBALS statements in b.4gl and c.4gl > unnecessary? > > Also, is the DATABASE statement in b.4gl and c.4gl unnecessary too? > > Any advice given would be welcome. > > Cheers, Ian. > -- Dennis J. Pimple Principal Consultant Informix Software Inc. -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum