Fwd: Re: Nesting a group of If then & else statements in a
Posted in 1999
---- Original Msg from: Jonathan Leffler <jleffler@earthlink.net> At: 11/ 6 2: Too much I4GL; not enough ACE? END IF is not part of ACE. You only use the END when you also use BEGIN. So, although you're right you can use ELSE IF, all you need is: IF field1 = "01" AND field2 = "03" THEN PRINT "bank" ELSE IF field1 = "11" AND field2 = "12" THEN PRINT "JUDG" ELSE IF filed1 = "08" THEN PRINT "NEXT" Note that I've preserved the typo in the original question. You may post this if you wish. "Art S. Kagel" wrote: > Shirlene Mosley wrote: > > > > I am having trouble nesting a group of if then & else statements in a report > > It only takes the first (if then & else ) value and the rest are ignored. > > > > e.g. if field1 = "01" and field2 = "03" then print "bank" or > > if field 1 = "11" and field2 = "12" then print "JUDG" or > > if filed1 = "08" then print "NEXT" > > the first value is tested and the rest are ignored. > > Mariusz's example will work. Although ACE does not support an ELSE IF > construct you can fake it and make the code more readable. Thus: > > IF field1 = "01 AND field2 = "03" THEN > PRINT "bank" > ELSE IF field1 = "11" AND field2 = "12" THEN > PRINT "JUDG" > ELSE IF field1 = "08" THEN > PRINT "NEXT" > END IF END IF END IF > > This uses nesting as if there were an else if construct. If you prefer, > this is really: > > IF field1 = "01 AND field2 = "03" THEN > PRINT "bank" > ELSE > IF field1 = "11" AND field2 = "12" THEN > PRINT "JUDG" > ELSE > IF field1 = "08" THEN > PRINT "NEXT" > END IF > END IF > END IF > > Art S. Kagel -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>