Using Var-Shift To Obtain Array Elements - 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 Arrays

Using var-shift to Obtain Array Elements

Cisco Content Services Switch Administration Guide
8-24
You can use this method to figure out how many times to perform a while
command. For example, enter:
set WeekDays "Sun Mon Tues Wed Thurs Fri Sat"
set Counter "1"
while Counter "LTEQ" "${WeekDays}[#]"
echo "Counter is set to ${Counter}."
modify Counter "++"
endbranch
The output is:
Counter is set to 1.
Counter is set to 2.
Counter is set to 3.
Counter is set to 4.
Counter is set to 5.
Counter is set to 6.
Counter is set to 7.
You may need to print out all the days of the week to the screen. While it is
possible to print out each array element by hardcoding the element values, it is not
always practical or possible to do this. In this case, it is obvious that there are
seven days in the week, but there may be cases where the number of elements in
a variable are unknown until the script is executed.
Use the var-shift command to push an element out of an array one at a time. For
example, enter:
set WeekDays "Sun Mon Tues Wed Thurs Fri Sat"
while ${WeekDays}[#] "GT" "0"
! Push the 1st element out of the array and shift all
! elements up one position.
echo "Day: ${WeekDays}"
var-shift WeekDays
endbranch
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