<# endwhile #>
<# while stars > 0, stars := substr(stars, 0, stars-1)#>
!<# stars;"\n" #>
<# endwhile #>
<# // An example of the continue and break statements. #>
<# // Also note that many statements can be grouped. #>
! All the positive even numbers less than 11
<# i:=0; while ++i < 100 #>
<#if i%2; continue; endif; if i > 10; break; endif; "!" $ i $ "\n"; #>
<# endwhile #>
<# // While constructs will NOT iterate forever. #>
<# while 100 > 0 // This is always true, but the macro will eventually stop #>
<# ++iterations; endwhile #>
! The while loop iterated <#iterations#> times.
<# endtmpl #>
Passing Parameters in Macros
You can pass parameters to an entry macro. The system translates these parameters
to the correct data type.
NOTE:
The env.argv array is separate from this feature and still functions as
designed. In other words, the env.argv array continues to pass parameters
as text strings. To use env.argv array values for subsequent numeric
operations, you must first convert the values to a number by using the
env.atoi(string) command.
Example
The following macro (saved as
m.mac
) uses values specified in a CLI command to
compute the final result:
<# m(left,right,third) #>
<# multi := left * right #>
<# multiFinal := multi * third #>
<# setoutput console #>
<# “ The result is: multiFinal; “ \n” #>
<# endsetoutput #>
<# endtmpl #>
The following example provides the output from using this macro:
host1#
macro m.mac m 5 6 7
host1#The result is: 210
Generating Macro Output
You may want a macro to provide output while it is operating. In simple cases, you can
use the
verbose
keyword to echo commands to the display and display comments as
the macro executes. For more information about the
verbose
keyword, see “Example 2”
on page 468 in “Invoking Other Macros” on page 475.
When running more complex macros or macros that contain a lot of commands or
comments, you may want to output only certain information (that is, not all commands
and comments). In this case, you can use <# setoutput console #> to send the information
directly to the console display when it executes.
Copyright © 2010, Juniper Networks, Inc.
474
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...