Re: How to call a Informix 4gl rutine from another 4GL rutine .
Posted in 1998
Hey Nils, True, I've worked too long with RDS but I've also worked too long with 4gl compiled (I need some Java :). What you say may be true for some versions on some platforms. I did some testing on this a few years ago and I just did some testing a few minutes ago and the results are completely consistent between RDS and compiled 4gl. Modular variables are initialized automatically to null except for integers that initialize to zero (both RDS and compiled 6.05.UC1). Maybe it's dumb luck. I agree that using variables without manually initializing them is shaky and should be avoided. I don't remember anything in the manuals that say that variables are automatically intialized so any future changes, not to mention third-party compilers (4js, Querix) may behave differently. Calling a function like you said to initialize the modular variable beforehand is good practice, but in some cases you don't know beforehand whether the function will be called, and when it is called you don't know if it has already been called. This would require you to call an initializing function at the beginning of your application for every recurs-checking function. Maybe Marco Greco can shed some light on what he does. I recall him saying that in his application(s) the user can call any window from within any window. This would require recursion which means you either have to not use modular variables for those functions or somehow inhibit recursion - Marco? Not using modular variables for functions that have alot of sub-functions can be tedious and inefficient because you have to send so many parameters between those functions. I've always found this to be a drawback with C (and therefore 4gl) to not be able to define functions within functions, the child functions inheriting variables defined in it's parent. Ok, I'm sidetracking. Nils Myklebust wrote: > > Hey John F. > You have been working far too long with RDS. > Your r_flag variable will by definition be an uninitialized variable > that may have any value when the routine is called the first time. > That's the way it is with 4GL compiled. That's the way you therefore > HAVE to expect it to be with RDS. > > This is easy to solve however. Simply create another function that you > call before all this that initializes r_flag to false. > We do such initializations all the time with module level variables > and we use those a lot. > > On Wed, 11 Feb 1998 12:08:28 +0000, "John H. Frantz" <john@rl.is> > wrote: > > >I assume you mean function A calls function B which may end up calling > >function A again directly or indirectly. If this is the case you could > >define a modular variable (defined at the top of a module above the > >first function statement) to flag any recursion, something like: > > > >define r_flag char > > > >function my_func() > >if r_flag then > > error "already called" > >else > > let r_flag = true > > call my_func_norecurs() > > let r_flag = false > >end if > >end function > > > >function my_func_norecurs() > >... the real function. > >end function > > > >The variable r_flag will be null the first time the function is called. > > > >Augusto Carnero wrote: > >> > >> Hello. > >> > >> I would like to know, if there is any way to avoid the recursive call of a > >> informix 4Gl rutine. I mean , my intention is to make a 4GL rutine from > >> another 4Gl rutine, without the use of the recursive method. > >> If anybody can response this question I would apreciate it. > >> > >> thanks in advance. > >> > >> Augusto. > >> > >> acarnero@ven.net > > > >---------------------------------------------------------------------- > >John H. Frantz Power-4gl: Extending Informix-4gl > >john@rl.is http://www.rl.is/~john/pow4gl.html > > Nils Myklebust > NM Data AS > Norway > E-mail: Nils.Myklebust@nmdata.com -- ---------------------------------------------------------------------- John H. Frantz Power-4gl: Extending Informix-4gl john@rl.is http://www.rl.is/~john/pow4gl.html