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.
Example
<# 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.
Example
<# 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:
while
postdecrement
predecrement
assignment
postincrement
preincrement
if
Example
<# localvar #>value of localvar is written
<# " any string" #>“ any string” written
<# 4 % 3 + 12 - 6 #>“ 7” is written
<# 4 % (3 + 12) - 6 #>“ -6” is written
<# i := i + 1 #>nothing is written
<# count := (count - 2) #>nothing is written
Conditional Execution
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
471
Copyright © 2010, Juniper Networks, Inc.
Chapter 8: Writing CLI Macros
Содержание JUNOSE 11.3
Страница 6: ...Copyright 2010 Juniper Networks Inc vi...
Страница 8: ...Copyright 2010 Juniper Networks Inc viii JunosE 11 3 x System Basics Configuration Guide...
Страница 24: ...Copyright 2010 Juniper Networks Inc xxiv JunosE 11 3 x System Basics Configuration Guide...
Страница 32: ...Copyright 2010 Juniper Networks Inc 2 JunosE 11 3 x System Basics Configuration Guide...
Страница 146: ...Copyright 2010 Juniper Networks Inc 116 JunosE 11 3 x System Basics Configuration Guide...
Страница 166: ...Copyright 2010 Juniper Networks Inc 136 JunosE 11 3 x System Basics Configuration Guide...
Страница 432: ...Copyright 2010 Juniper Networks Inc 402 JunosE 11 3 x System Basics Configuration Guide...
Страница 488: ...Copyright 2010 Juniper Networks Inc 458 JunosE 11 3 x System Basics Configuration Guide...
Страница 524: ...Copyright 2010 Juniper Networks Inc 494 JunosE 11 3 x System Basics Configuration Guide...
Страница 554: ...Copyright 2010 Juniper Networks Inc 524 JunosE 11 3 x System Basics Configuration Guide...
Страница 566: ...Copyright 2010 Juniper Networks Inc 536 JunosE 11 3 x System Basics Configuration Guide...
Страница 588: ...Copyright 2010 Juniper Networks Inc 558 JunosE 11 3 x System Basics Configuration Guide...
Страница 613: ...PART 3 Index Index on page 585 583 Copyright 2010 Juniper Networks Inc...
Страница 614: ...Copyright 2010 Juniper Networks Inc 584 JunosE 11 3 x System Basics Configuration Guide...
Страница 632: ...Copyright 2010 Juniper Networks Inc 602 JunosE 11 3 x System Basics Configuration Guide...