Re: Accessing program variables across 4gl files in the same executable
Posted in 1998
1. I believe 4j's compiler (http://www.4js.com) is providing this capability - here's an excerpt from some documentation: "PUBLIC DEFINE" The variables defined in that way may also be used in other modules. By using this variable in other modules, the name of the variable must be prefixed with the module name as shown in the following example: "LET module-name.variable-name = ..." Looks like they're pushing the language further (you can even define classes etc.) - maybe they will be the future standard 4gl source. ---------------------------------------------------------------------- 2. With standard 4gl all variables are "private" while all functions are "public". This means you can resort to a method illustrated in the following example: define modvar char(10) function get_modvar() return modvar end function function set_modvar(v) define v char(10) let modvar = v end function You can now access modvar from any module using these two functions. This avoids using global variables which can be messy to maintain. Usage depends on circumstances. ---------------------------------------------------------------------- John H. Frantz Power-4gl: Extending Informix-4gl john@rl.is http://www.rl.is/~john/pow4gl.html Manish Hemrajani wrote: > > Hi > > Is it possible to access program variables (i.e. variables declared > before "main" dont confuse these with globals) across 2 or more 4gl > programs within the same executable (.4ge file). > > Say for example I have one 4gl program containing the "main" and "end > main" which in turn calls functions which are declared in another 4gl > program. Can these 2 programs access a common set of variables (similiar > to "extern" variables in "C") > > Thanks > Manish