Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    else if

    Syntax

    if (expression) {
            /* code */
    }
    else if (expression) {
            /* code */
    }

    Release Information

    Statement introduced in version 1.0 of the SLAX language.

    Description

    Include instructions that are processed if the expression defined in the preceding if statement evaluates to FALSE and the expression defined in the else if statement evaluates to TRUE. Multiple else if statements can be included, but the processor only executes the instructions contained in the first else if statement whose expression evaluates to TRUE. All subsequent else if statements are ignored.

    SLAX Example

    var $description2 = {
       if (description) {
          expr description;
       }
       else if (../description) {
          expr ../description; 
       }
       else {
          expr "no description found";
       }
    }

    XSLT Equivalent

    <xsl:variable name="description2">
       <xsl:choose>
          <xsl:when test="description">
               <xsl:value-of select="description"/>
          </xsl:when>
          <xsl:when test="../description">
             <xsl:value-of select="../description"/>
          </xsl:when>
          <xsl:otherwise>unknown</xsl:otherwise>
       </xsl:choose>
    </xsl:variable>

    Usage Examples

    See Example: Configuring Dual Routing Engines and Example: Automatically Configuring Logical Interfaces and IP Addresses.

    Published: 2013-03-05