Invoking Other Macros - 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

Example 1
<# setoutput console #>
This message appears in the console window (whether or not you use verbose mode).
<#endsetoutput #>
Example 2

Invoking Other Macros

Example 1
Copyright © 2010, Juniper Networks, Inc.
The following example shows how you can send output directly to the console:
The following example shows how you can send a single argument to the console:
<# puts (msg) #>
!==================================================================
!==================================================================
! output "msg" to console
!==================================================================
!==================================================================
<# setoutput console #>
<# msg; "\n"#>
<#endsetoutput #>
<# endtmpl #>
!==================================================================
!==================================================================
<# tmpl.puts(" Hello World" )
Macros can invoke other macros within the same macro file; a macro can also invoke a
macro from another macro file if the invocation takes place in literal text, that is, not
within a control expression. A macro can invoke itself directly or indirectly (an invoked
macro can invoke the macro that invoked it); the number of nested invocations is limited
to 10 to prevent infinite recursion.
Within each macro, you can specify parameters that must be passed to the macro when
it is invoked by another. You must specify named variables enclosed in parentheses after
the macro name in the first line of the macro, as shown in this example:
<# macroName (count, total) #>
Additional parameters can be passed as well. Parameters can be local variables,
environmental variables, literals, or operations. The invoking macro passes local variables
by reference to the invoked macro. Passing parameters has no effect on the invoking
macro unless the parameter is a local variable that is changed by the invoked macro.
When the invoked macro completes execution, the local variable assumes the new value
for the invoking macro.
The invoked macro can use the param[ n ] expression to access parameters passed to
it, where n is the number of the parameter passed. This is useful if optional parameters
can be passed to a macro or if the same iterative algorithm needs to process the
parameters.
Use the expression param[0] to return the total number of parameters passed to the
macro. Use the return keyword to halt execution of the invoked macro and resume
execution of the invoking macro. Use the exit keyword to halt execution of all macros.
The following sample macro demonstrates macro invocation:
<#
invoking_examples
<# //---------------------------------------- #>
<# name := env.getline("What is your first name? ") #>
Chapter 8: Writing CLI Macros
#>
475

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junose 11.3

Table of Contents