Kbase P11691: 4GL: how to write a CASE statement with a IF THEN ELSE structure.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  21/07/2005 |
|
Status: Verified
GOAL:
How to write a CASE statement with a IF THEN ELSE structure.
FIX:
Here there is a sample on a CASE statement and his correspondent IF THEN ELSE structure.
CASE cVar:
WHEN "AAA" THEN
MESSAGE "Condition 0" VIEW-AS ALERT-BOX INFO BUTTONS OK.
WHEN "BBB" THEN
MESSAGE "Condition 1" VIEW-AS ALERT-BOX INFO BUTTONS OK.
WHEN "CCC" THEN
MESSAGE "Condition 2" VIEW-AS ALERT-BOX INFO BUTTONS OK.
OTHERWISE
MESSAGE "Other cases" VIEW-AS ALERT-BOX INFO BUTTONS OK.
END CASE.
/* the correspondent if then else structure is:*/
IF cVar = "AAA" THEN
MESSAGE "Condition 0" VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE IF cVar = "BBB" THEN
MESSAGE "Condition 1" VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE IF cVar= "CCC"THEN
MESSAGE "Condition 2" VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE
MESSAGE "Other cases" VIEW-AS ALERT-BOX INFO BUTTONS OK.
Please note that from a performance point of view, the CASE statement is a faster statement than the IF...THEN...ELSE one.