Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Conditionally executes a group of statements, depending on the value of an expression.
@if (
   condition1
)
   text1
[@elif (
   condition2
)
   text2]
[@else
   text3]
@end 
Arguments
- condition1, condition2 
 Required. An expression that can be coerced into a Boolean expression.
- text1 
 Optional. Text to be parsed if condition1 is true.
- text2 
 Optional. Text to be parsed if condition1 is false and condition2 is true.
- text3 
 Optional. Text to be parsed if both condition1 and condition2 are false.
Remarks
When you write an @if statement, you do not have to place each clause on a separate line. You can use multiple @elif clauses. However, all @elif clauses must come before an @else clause.
You commonly use the @if statement to determine which text among several options should be used for text output.
Example
The following command-line program illustrates the use of the **@if...@elif…@else...@end** statement.
@cc_on
print("JScript version: " + @_jscript_version);
@if (@_win32)
    print("Running on a 32-bit version of Windows");
@elif (@_win16)
    print("Running on a 16-bit version of Windows");
@else
    print("Running on a different operating system");
@end
Requirements
See Also
Concepts
Conditional Compilation Variables
Reference
Other Resources
Change History
| Date | History | Reason | 
|---|---|---|
| August 2009 | Modified remarks and example. | Content bug fix. | 
| March 2009 | Modified remarks and example. | Information enhancement. |