Re: scope of WHENEVER statement
Posted in 2000
Tony Flaherty wrote: > > Whenever is essentially a compiler directive. from the INFIRMIX-4GL manual > page 3-280 > > "Using whenever is equivalent to including code after every SQL stmnt..... > to take the specified action if the exceptional condition is detected." > > >From page 3-281 > "The scope of WHENEVER stmnt is from its location in a program block until > the next WHENEVER stmnt .... in the same module, ..... the WHENEVER stmnt > remains in effect...... until the end of the module." > > You can of course set different WHENEVER error actions for each function if > you wish, as in Steve's example. It is not however being changed at run > time, the error checking code added by the compiler is different for > function xyz because of the placement of the WHENEVER stmnts. Correct. > Mmm, you can see why I'm a programmer and not an English teacher eh! ;o)) Made perfect sense to me...., but then I'm not an English teacher either. ;-) > The big question is how do you indent the whenever stmnts in your code when > they can span function definitions? That's a good question. The answer is, I DON'T! I also advise my students to get in the habit of left justifying WHENEVER so that it stands out when debugging. Also, indented code follows the logic flow, which WHENEVER does not, as you say. Cheers, -- Mark. +----------------------------------------------------------+-----------+ | Mark D. Stock mailto:mdstock@mydas.freeserve.co.uk |//////// /| | http://www.informix.com http://www.informixhandbook.com |///// / //| | http://www.iiug.org +-----------------------------------+//// / ///| | |What year 2000 bug? year 2000 bug? |/// / ////| | |year 2000 bug? year 2000 bug? year |// / /////| | |2000 bug? year 2000 bug? year 1900 |/ ////////| +----------------------+-----------------------------------+-----------+