Re: WHENEVER ANY ERROR
Posted in 1997
Jojean (jojean@aol.com) writes: >X-Informix-List-Id: <news.41012> [...Question about WHENEVER ANY ERROR omitted -- I've not seen that problem...] >Also when we compile the program (c4gl -c prog_name.4gl) we are getting >the following warning message: > > prog_name.ec, line 524: warning: statement is unreachable > break;}} while(0); > >This is what some of the code looks like. [...some code omitted...] >function next_prev(flag,flag2,first_time) [...code omitted...] > case > when flag = 1 [...code omitted...] > exit case > when flag = 2 [...code omitted...] > exit case > when flag = 3 > exit case > otherwise > return > exit case > end case [...more code omitted...] I think your compilation warning is coming from the 'return' followed by 'exit case'. Because the RETURN is an unconditional departure from the CASE statement, the EXIT CASE cannot be executed. You should not have any statements after the unconditional RETURN. More seriously, you have EXIT CASE in the 'WHEN flag = 1' clauses which does not buy you anything. I4GL is not C; each WHEN clause automatically skips to the end of the CASE on complettion, and there is no way to flow through from one WHEN clause to the next. The EXIT CASE for 'WHEN flag = 3' is needed (well, excusable at any rate), but the others are redundant at best and in the OTHERWISE clause, plain wrong. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: Warning I do not reply to messages with anti-spam in the return path.