Using Functions; Passing Arguments To A Function - Cisco 11503 - CSS Content Services Switch Administration Manual

Content services switch
Hide thumbs Also See for 11503 - CSS Content Services Switch:
Table of Contents

Advertisement

Using Functions

Using Functions

Passing Arguments to a Function

Cisco Content Services Switch Administration Guide
8-28
Functions provide a way to organize your scripts into subroutines or modules. You
can then call these functions as your script requires them.
To modularize your scripts both for ease of reading and simplification, use the
function command. This command allows both the creation and calling of script
functions. For example, enter:
echo "Calling the PrintName function"
function PrintName call
echo "End"
! Function PrintName: Prints the name John Doe
function PrintName begin
echo "My Name is John Doe"
function PrintName end
The output is:
Calling the PrintName function
My Name is John Doe
End
Notice that the command issued between the commands function PrintName
begin and function PrintName end executes before the last echo statement in the
script. Also note that the script automatically terminates after the last valid line
before the function definition.
You can pass a list of arguments to a function. (This is similar to passing command
line arguments to a script.) You can also use those arguments when the script calls
the function. For example, enter:
echo "Calling the PrintName function"
function PrintName call "John Doe"
echo "End"
! Function PrintName: Prints the name John Doe
function PrintName begin
echo "My Name is ${ARGS}"
function PrintName end
The output is:
Chapter 8
Using the CSS Scripting Language
OL-5647-02

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents