Cisco 11503 - CSS Content Services Switch Administration Manual page 293

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

Advertisement

Chapter 8
Using the CSS Scripting Language
Using Arrays
The output of this logical block is:
Day: Sun
Day: Mon
Day: Tues
Day: Wed
Day: Thurs
Day: Fri
Day: Sat
You cannot use a variable as the index to obtain a given element in an array. So
the following statement is invalid:
set Pet "Dog Cat"
set Index "1"
echo "First Pet is: ${Pet}[${Index}]"
modify Index "+" 1
echo "Second Pet is: ${Pet}[${Index}]"
However, the following statement can solve this problem:
set Pet "Dog Cat"
echo "First Pet is: ${Pet}[1]"
var-shift Pet
echo "Second Pet is: {$Pet}[1]"
Notice in the second Pet example that there is one less variable needed (you do
not need the Index variable) and the first element index (${Pet}[1]) is the only one
used.
The var-shift command deletes the original data within the variable. The variable
Pet from the example above now contains only the element "Cat". To solve this
problem, save the contents of the original variable in a temporary variable.
For example, enter:
set Pet "Dog Cat"
set Temp "${Pet}"
echo "First Pet is: ${Temp}[1]"
var-shift Temp
echo "Second Pet is: {$Temp}[1]"
no set Temp
By using the Temp variable, you leave the original variable untouched. If you
decide you no longer need the Temp variable, remove it from memory with the no
set command.
Cisco Content Services Switch Administration Guide
8-25
OL-5647-02

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents