Initializing an Array Slice
The following macro initializes an array slice to a constant value:
array_set (lower_bound upper bound var val) {
for { set i $lower_bound } { $i <= $upperbound } { 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. Here is how you use this function:
d1.<> dprint list3
list3 = {
(1) = 1 (0x0000001)
(2) = 2 (0x0000001)
(3) = 3 (0x0000001)
}
d1.<> array_set 2 3 list 3 99
d1.<> dprint list3
list3 = {
(1) = 1 (0x0000001)
(2) = 99 (0x0000063)
(3) = 99 (0x0000063)
}