Re: 4GL and $DBNAME
Posted in 1998
On Tue, 23 Jun 1998 01:32:01 +0100, Stefan Weideneder <stefan@weideneder.de> wrote: >Bruce McDougald wrote: >> >> I want to write 4gl code that will grab the database name from an env. >> variable at compile time. My problem is that the compiler is choking on >> my variable definitions. Is there a way around this? >> >> EX: >> main >> call init() >> call process() >> end main >> >> function init() >> define dbname >> let dbname = fgl_getenv("DBNAME") >> >> database dbname >> end function >> >> function process() >> define l_var like table.column ## Compiler will choke here >> ..... >> end function > >You forgot to write the database definition at the top of your >program. > >DATABASE compilerdatabase # this database will be used by the compiler > >MAIN >define > > dbname char(80) > > let dbname = fgl_getenv( "DBNAME" ) > DATABASE dbname # this database will ne used during runtime > >END MAIN > >Bye > >Stefan Weideneder There is a significant problem with this: The database statement in the source module that contains the main-function have the added effect of including an open of that database in the code before anything else is executed. Using the above code both the "compilerdatabase" and the dynamically set database would have to be present at runtime. Even if they allways are you get an additional open (or connect) to the compilerdatabase that isn't needed. What you do instead is what Jonathan allready explained about no database statement at the beginning of the module containing the main function, only in the other modules where it doesn't cause a database to be opened, but is only used at compile time. Nils Myklebust NM Data AS Norway E-mail: Nils.Myklebust@nmdata.com FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html (Now with ODBC info under "Third party products".)