Passing Parameters In Macros; Generating Macro Output - Juniper JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 Configuration Manual

Software for e series broadband services routers system basics configuration guide
Hide thumbs Also See for JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04:
Table of Contents

Advertisement

JunosE 11.3.x System Basics Configuration Guide

Passing Parameters in Macros

Example

Generating Macro Output

474
<# 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 #>
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.
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
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.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junose 11.3

Table of Contents