Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

setarray

setarray( 
a_array 
x_index 
g_value 
) 
=> g_value
setarray( 
o_table 
g_key 
g_value 
) 
=> g_value

Description

Assigns the given value to the specified element of an array or to the specified key of a table. Normally this function is invoked implicitly using the array-subscription syntax, such as, x[i] = v.

Assigns g_value to the x_index element of a_array, or adds the association of g_value with g_key to o_table, and returns g_value. Normally this function is invoked implicitly using the array-subscription syntax, such as, x[i] = v.

Arguments

a_array

An array object.

x_index

Index of the array element to assign a value to. Must be between 0 and one less than the size of the array.

g_key

Any SKILL value.

g_value

Value to be assigned to the specified array element or table entry.

Value Returned

g_value

Value assigned to the specified array element or table entry.

Examples

declare(myar[8])    
=> array[8]:3895304
myar[0]
=> unbound
setarray(myar 0 5)
=> 5
myar[0]
=> 5
setarray(myar 8 'hi)

Signals an array bounds error.

setarray(myar 
(plus 1 2) ; assigns element 3 the value 8.
(plus 3 5))
=> 8
mytab = makeTable('myTable) 
=> table:myTable
setarray(mytab 8 4)  
=> 4
mytab[8]
=> 4
mytab[9] = 3
=> 3 ; same as setarray(mytab 9 3)
mytab[9]
=> 3

Related Topics

arrayref

declare


Return to top
 ⠀
X