If ElemSpec is a compound term, it must specify an element of a visible non-logical array, all its arguments must be non negative integers smaller than the bounds specified with array/1/2 or variable/1. The copied value of the array element is unified with Value.
If Element is the name of a reference, Value is unified with the actual term the reference refers to (no copying involved).
Success:
local(array(a(4), float)),
setval(a(2), 2.0),
getval(a(2), 2.0).
setval(i, "2"),
getval(i, V)). (gives V = "2").
Failure:
local(array(a(2))),
setval(a(1), 8.6),
getval(a(1), 10.0).
setval(i, 3),
getval(i, 0)).
Error:
getval(X, 1). (Error 4).
getval(a(X), 1). (Error 4).
getval("a", V). (Error 5).
getval(a(2.0), V). (Error 5).
getval(a(-1), V). (Error 6).
getval(no_array(0), X). (Error 41).
getval(no_var, X). (Error 41).