Forum Discussion

SST_87455's avatar
SST_87455
Icon for Nimbostratus rankNimbostratus
Apr 22, 2019

IRule requires "else" clause?

Loading a SCF config file into new hardware. Getting this warning.

 

/Common/down4maint_offline_f5_hosted:15: warning: [deprecated usage, use else or elseif][ ]

 

Being told by support that if statement needs an else clause. Seems pretty silly. Never seen a language that requires an else clause. Makes no sense if the logic is just to continue. Any ideas on the best way to correct this warning?

 

3 Replies

  • If there is a condition like

    else {}
    ,then remove the
    {}
    or use
    elseif
    command instead of
    else
    .

  • hello,

    You should have an irule like that:

    if {$host contains "app1"} {
         condition
    } elseif {$host contains "app2"} {
         condition
    } else {$host contains "app3"} {
         condition
    }
    

    The else should not be conditional, so either use elseif again, or remove the condition in your else.

    if {$host contains "app1"} {
         condition
    } elseif {$host contains "app2"} {
         condition
    } else {
         condition
    }
    

    Similar problem: https://devcentral.f5.com/questions/http_request-amp-if-elseif-else-statements

    if my answer don't resolve your problem can you give me your irule in order to check it.

    Regards