elseif
Other versions of this page are also available for the following:
8/28/2008
This command indicates a conditional alternative in an If statement.
The elseif boolean command does a Boolean comparison.
The elseif datetime command does a date comparison.
The elseif number command does a numeric comparison.
The elseif string command does a case-sensitive string comparison. The contains
operator is used to see if a given string contains a particular substring, in a manner similar to the C language strstr function.
The elseif version command does a comparison between two version strings.
Syntax
elseif boolean [boolean string] [ == | != ] [boolean string]
elseif datetime [datetime string] [ == | != | < | <= | > | >=] [datetime string]
elseif number [numeric string] [ == | != | < | <= | > | >=] [numeric string]
elseif string [string] [ == | != | < | <= | > | >= | contains] [string]
elseif version [version string] [ == | != | < | <= | > | >=] [version string]
Parameters
- boolean string
The Boolean strings can be either TRUE, ON, YES, or 1 to represent a logical 1 or they can be either FALSE, OFF, NO, or 0 to represent a logical 0.
datetime string
The datetime string represents a particular date and time and is specified as<4 digit year>-<month number>-<month day> <hours>:<minutes>:<seconds>
. The right-hand side datetime string can also be one of the following special keywords:yesterday
lastmonth
today
thismonth
tomorrow
nextmonth
lastweek
lastyear
thisweek
thisyear
nextweek
nextyear
These keywords can be used instead of specific dates to make scripts operative on relative time values.
- numeric string
Each of the two numeric string specifies the numbers you want to do a numeric comparison on.
- string
Each of the two string specifies the strings you want to do a case-sensitive string comparison on.
- version string
Each of the two version string specifies the versions you want to do a version comparison on.
Remarks
You can specify multiple expressions to evaluate on a single command line using the OR operator between the expressions.
The following code example uses the elseif command to decide which message to output:
if string "%CCA_CURRENTLANGUAGE%" == "en-US"
echo "Hello World"
elseif string "%CCA_CURRENTLANGUAGE%" == "fr-CA"
echo "Bonjour le Monde"
else
echo "Hello"
endif