Cisco 11503 Administration Guide - Page 296
Using Functions, Passing Arguments to a Function
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 296 highlights
Using Functions Chapter 8 Using the CSS Scripting Language Using Functions 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. Passing Arguments to a Function 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: 8-28 Cisco Content Services Switch Administration Guide OL-5647-02