Initializing an Array Slice
The following macro initializes an
array slice to a constant value:
array_set (var lower_bound upper_bound val) {
for {set i $lower_bound} {$i <= $upper_bound} {incr i}{
dassign $var\($i) $val
}
}
The CLI dassign command assigns a value to a variable. In this case, it is setting the value of an array element. Use this function as follows:
d1.<> dprint list3
list3 = {
(1) = 1 (0x0000001)
(2) = 2 (0x0000001)
(3) = 3 (0x0000001)
}
d1.<> array_set list 2 3 99
d1.<> dprint list3
list3 = {
(1) = 1 (0x0000001)
(2) = 99 (0x0000063)
(3) = 99 (0x0000063)
}
For more information on slices, see
Displaying Array Slices.