Re: A question regarding WHENEVER
Posted in 1996
Stuart Knight wrote: > > > A straightforward question this one (hopefully!!): > > Are WHENEVER clauses interpreted, or are they compiler directives ? > > eg. > > FUNCTION func1 () > > WHENEVER ERROR CONTINUE > > processing...... > > > RETURN TRUE > > WHENEVER ERROR STOP <-- Would this statement ever be acted upon ? > (or should it be before the RETURN statement) > END FUNCTION > > > After asking several of my colleagues, I could not come up with a > definitive answer. Any comments would be most welcome. > > Regards, > > Stuart Knight. > > eMail: stuart_knight@lendlease.com.au > > "Any opinions expressed are mine and not necessarily those of my > employer" Be very careful with the WHENEVER clause, RTFM and check the release notes for clarification. I have found a number of 4GL programmers who do not understand the workings The clause is a compiler directive, it effects all the code generated after the clause appears, UP TO THE END OF THE SOURCE CODE FILE. In your example the WHENEVER ERROR STOP would take effect in func2(), provicec it followed func1() AND IS IN THE SAME SOURCE CODE FILE. Yhe following statement will not operate as expected IF ...... THEN WHENEVER ERROR STOP ELSE WHENEVER ERROR CONTINUE END IF The WHENEVER ERROR CONTINUE will always be in force until the end od the 4GL file. I have had a number of problems where a program has a WHENEVER clause in the first module but no clauses in other source code modules. I read once (release notes?) that Informix recommend the use of WHENEVER ANY ERROR clause in new applications. But RTFM and try it out with a test program. Peter