Example
Example
Example
Conditional Execution
Copyright © 2010, Juniper Networks, Inc.
Miscellaneous Operations
The positive (+) and negative (-) operations must precede the operand. The result of a
positive operation is the absolute value of the operand. The result of a negative operation
is the negative value of the operand; that is, a +(-5) becomes 5 and a -(-2) becomes 2.
These operators have the same precedence as the increment and decrement operators.
If there is an operand on both sides of these operators, they are interpreted as the add
and subtract operators.
<# local_abs := +local #>
<# local_neg := -local #>
All operations are performed in the order implied by the precedence of the operators.
However, you can modify this order by using parentheses (( )) to group operands and
operators. Operations within parentheses are performed first. The result is that of the
operations within the parentheses.
<# 4 % (3 + 12) - 6 #>The result is -6
<# 5 && 2 > 1 #>The result is 1
<# (5 && 2) > 1 #>The result is 0
Results of control expressions are written to the output stream when the expression
consists of the following:
A single local variable
A single literal element
An operation whose result is not used by one of the following operations:
assignment
predecrement
if
preincrement
<# localvar #>value of localvar is written
<# " any string" #>"
any string"
<# 4 % 3 + 12 - 6 #>" 7"
<# 4 % (3 + 12) - 6 #>" -6"
<# i := i + 1 #>nothing is written
<# count := (count - 2) #>nothing is written
You can use if or while constructs in macros to enable conditional execution of commands.
If Constructs
If constructs provide a means to execute portions of the macro based on conditions that
you specify. An if construct consists of the following components:
An opening if expression
A group of any number of additional expressions
(Optional) Any number of elseif expressions and groups of associated expressions
postdecrement
postincrement
written
is written
is written
Chapter 8: Writing CLI Macros
while
471
Need help?
Do you have a question about the JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 and is the answer not in the manual?
Questions and answers