Cisco 11503 Administration Guide - Page 292
Using var-shift to Obtain Array Elements
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 292 highlights
Using Arrays Chapter 8 Using the CSS Scripting Language 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. Using var-shift to Obtain Array Elements 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 8-24 Cisco Content Services Switch Administration Guide OL-5647-02