EasyManuals Logo

Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X User Manual

Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X
640 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #517 background imageLoading...
Page #517 background image
<# if 0 #>
! This is never output because a value of zero is false.
<# endif #>
<# // Heres 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. Thats nice.
<# endif #>
<# // Heres 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";
shade := env.getline("Do you prefer dark " $ color $
" or light " $ color $ "? ") #>
<# if shade = "dark" #>
! I like dark colors, too.
<# elseif shade = "light" #>
! I prefer dark colors myself.
<# else #>
! Hmmm, thats neither dark nor light.
<# endif #>
<# else #>
! Oh. Thats nice.
<# endif #>
<# else #>
! I didnt think so!
<# endif #>
<# endtmpl #>
While Constructs
While constructs provide a means to repeatedly execute one or more portions of the
macro based on a condition that changes during the execution. A while construct
consists of the following components:
An opening while expression
A group of any number of additional expressions
An endwhile expression to indicate the end of the while structure
The while expression must include a lone environment value command, a local
variable, a literal, or some operation using one or more operators. Each time that
this expression evaluates to nonzero, the associated expression group is executed.
You can place an iteration expression after the while expression. This optional
expression is evaluated after each execution of the while expression group.
You can include if structures within a while structure. You can also include special
control expressions indicated by the break or continue expressions. The break
expression breaks out of the while structure by halting execution of the expression
group and executing the first expression after the endwhile statement. The continue
Writing Macros 487
Chapter 8: Writing CLI Macros

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X and is the answer not in the manual?

Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X Specifications

General IconGeneral
BrandJuniper
ModelSYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X
CategorySoftware
LanguageEnglish

Related product manuals