Conditional Execution; If Constructs - Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X Configuration Manual

System basics configuration guide software for e series broadband services routers
Table of Contents

Advertisement

JUNOSe 11.1.x System Basics Configuration Guide
<# 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:
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.
2.
3.
4.
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 1 #>
! This is always output because any nonzero value is " true."
<# endif #>
486
Writing Macros
An opening if expression
A group of any number of additional expressions
(Optional) Any number of elseif expressions and groups of associated expressions
(Optional) An else expression and any associated group of expressions
An endif expression to indicate the end of the if structure
The if expression is evaluated. If the result is true (nonzero), the associated
expression group is executed.
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.
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.
This evaluation process continues until an expression evaluates to nonzero. If
there is no nonzero evaluation, then no expression group is executed.
if_examples
#>

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junose 11.1

Table of Contents