Cisco 11503 Administration Guide - Page 291
Element Numbers
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 291 highlights
Chapter 8 Using the CSS Scripting Language Using Arrays However, if you want to print out each day separately, you must refer to a single element within the array. For example, enter: echo "The first day of the week is ${WeekDays}[1]." echo "The last day of the week is ${WeekDays}[7]." The output is: The first day of the week is Sun. The last day of the week is Sat. Notice that you reference the array elements by putting the element number within brackets ([ and ]) to tell the CLI which element you want to use. You append the brackets to the end of the variable name (including variable indicator and braces). Note The CSS Scripting Language numbers elements starting at 1, not at 0. Some scripting/programming languages "zero index" their arrays; this scripting system does not. If you reference an element beyond the boundary of the array, you receive a syntax error. For example, enter: echo "The last day of the week is ${WeekDays}[8]" %% Error variable syntax This occurs because there is not an eighth element in the WeekDays array. Element Numbers To find out how many elements are in an array, pass the pound symbol (#) rather then an element value. For example, if you want to know how many days are in a week, enter: set WeekDays "Sun Mon Tues Wed Thurs Fri Sat" echo "There are ${WeekDays}[#] days in a week." The output is: There are 7 days in a week. OL-5647-02 Cisco Content Services Switch Administration Guide 8-23