![Juniper JUNOSE 11.3 Configuration Manual Download Page 502](http://html1.mh-extra.com/html/juniper/junose-11-3/junose-11-3_configuration-manual_2032852502.webp)
•
(Optional) An
else
expression and any associated group of expressions
•
An
endif
expression to indicate the end of the
if
structure
The
if
expression and any optional
elseif
expressions must include a lone environment
value command, a local variable, a literal, or some operation using one or more operators.
Only one of the groups of expressions within the
if
construct is executed, according to
the following scheme:
1.
The
if
expression is evaluated. If the result is true (nonzero), the associated expression
group is executed.
2.
If the result is false (zero), then the first
elseif
expression, if present, is evaluated. If
the result is true (nonzero), the associated expression group is executed.
3.
If the result of evaluating the first
elseif
expression is false (zero), the next
elseif
expression is evaluated, if present. If the result is true (nonzero), the associated
expression group is executed.
If all
elseif
expressions evaluate to false (zero) or if no
elseif
expressions are present,
then the
else
expression group—if present—is executed.
4.
This evaluation process continues until an expression evaluates to nonzero. If there
is no nonzero evaluation, then no expression group is executed.
You can write an empty expression group so that no action is performed if this group is
selected for execution. You can nest
if
structures within other
if
structures or
while
structures.
The following sample macro demonstrates various
if
structures:
<# if_examples #>
<# //---------------------------------------- #>
<# if 1 #>
! This is always output because any nonzero value is “ true.”
<# endif #>
<# if 0 #>
! This is never output because a value of zero is “ false.”
<# endif #>
<# // Here’s an example with elseif and else. #>
<# color := env.getline("What is your favorite color? ") #>
<# if color = "red" #>
! Red is my favorite color, too.
<# elseif color = "pink" #>
! Pink is a lot like red.
<# elseif color = "black" #>
! Black is just a very, very, very dark shade of red.
<# else #>
! Oh. That’s nice.
<# endif #>
<# // Here’s a nested if example. #>
<# sure := env.getline("Are you sure that " $ color $ " is your favorite color?
") #>
<# if substr(sure, 0, 1) = ’y’ || substr(sure, 0, 1) = ’Y’ #>
<# if color != "black" && color != "white";
Copyright © 2010, Juniper Networks, Inc.
472
JunosE 11.3.x System Basics Configuration Guide
Summary of Contents for JUNOSE 11.3
Page 6: ...Copyright 2010 Juniper Networks Inc vi...
Page 8: ...Copyright 2010 Juniper Networks Inc viii JunosE 11 3 x System Basics Configuration Guide...
Page 24: ...Copyright 2010 Juniper Networks Inc xxiv JunosE 11 3 x System Basics Configuration Guide...
Page 32: ...Copyright 2010 Juniper Networks Inc 2 JunosE 11 3 x System Basics Configuration Guide...
Page 146: ...Copyright 2010 Juniper Networks Inc 116 JunosE 11 3 x System Basics Configuration Guide...
Page 166: ...Copyright 2010 Juniper Networks Inc 136 JunosE 11 3 x System Basics Configuration Guide...
Page 432: ...Copyright 2010 Juniper Networks Inc 402 JunosE 11 3 x System Basics Configuration Guide...
Page 488: ...Copyright 2010 Juniper Networks Inc 458 JunosE 11 3 x System Basics Configuration Guide...
Page 524: ...Copyright 2010 Juniper Networks Inc 494 JunosE 11 3 x System Basics Configuration Guide...
Page 554: ...Copyright 2010 Juniper Networks Inc 524 JunosE 11 3 x System Basics Configuration Guide...
Page 566: ...Copyright 2010 Juniper Networks Inc 536 JunosE 11 3 x System Basics Configuration Guide...
Page 588: ...Copyright 2010 Juniper Networks Inc 558 JunosE 11 3 x System Basics Configuration Guide...
Page 613: ...PART 3 Index Index on page 585 583 Copyright 2010 Juniper Networks Inc...
Page 614: ...Copyright 2010 Juniper Networks Inc 584 JunosE 11 3 x System Basics Configuration Guide...
Page 632: ...Copyright 2010 Juniper Networks Inc 602 JunosE 11 3 x System Basics Configuration Guide...