mardi 23 février 2016

How to write this IF statement in a CASE in Progress 4GL?

I'm trying to give the user the opportunity to filter on an image. In my code I will receive a string like

ASSIGN img = "images\green.png". 

I think it would be best to write the following IF statement in a CASE, but I don't know how, since you can not use something like MATCHES or any other variable value in a CASE statement.

IF img MATCHES "*green*" THEN DO:
    MESSAGE "It's green!"
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
ELSE IF img MATCHES "*orange*" THEN DO:
    MESSAGE "It's orange!"
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
ELSE IF img MATCHES "*red*" THEN DO:
    MESSAGE "It's red!"
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.

So I obviously can't write it like this:

CASE img:
    WHEN MATCHES "*green*" THEN DO:
        MESSAGE "It's green!"
            VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END.
    WHEN MATCHES "*orange*" THEN DO:
        MESSAGE "It's red!"
            VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END
    WHEN MATCHES "*red*" THEN DO:
        MESSAGE "It's red!"
            VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END.
END CASE.

Any ideas or do I just leave it at the IF statement?

Aucun commentaire:

Enregistrer un commentaire