Do Case
This control structure lets you choose among multiple, mutually exclusive alternatives. You lay out the choices and exactly one is chosen. When you only have two choices, IF is more appropriate. To choose among alternatives in expressions, use IIF().
Usage |
DO CASE CASE lCondition1 Commands [ CASE lCondition2 Commands [ CASE lCondition3 Commands [ ... ] ] ] [ OTHERWISE Commands ] ENDCASE |
Example |
nThisYear = YEAR(DATE()) DO CASE CASE nThisYear - YEAR(Birth_Date) >= 70 ? 'Golden Oldie' CASE nThisYear - YEAR(Birth_Date) >= 60 ? 'SixtySomething' CASE nThisYear - YEAR(Birth_Date) >= 50 ? 'FiftySomething' CASE nThisYear - YEAR(Birth_Date) >= 40 ? 'FortySomething' CASE nThisYear - YEAR(Birth_Date) >= 30 ? 'ThirtySomething' CASE nThisYear - YEAR(Birth_Date) >= 20 ? 'Babe in the Woods' OTHERWISE ? 'Wunderkind' ENDCASE |
See Also |