Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

if

date_range 10-Feb-21

Syntax

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

Description

Include a conditional construct that causes instructions to be processed if the Boolean expression evaluates to TRUE.

Optionally, you can include multiple else if statements following an if statement to perform additional conditional tests if the expression in the if statement evaluates to FALSE. 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. The optional else statement includes a default set of instructions that are processed if the expressions defined in all associated if and else if statements evaluate to FALSE.

Attributes

expression

Specifies the expression to evaluate.

SLAX Example

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

XSLT Equivalent

content_copy zoom_out_map
<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>

Release Information

Statement introduced in version 1.0 of the SLAX language.

footer-navigation