[ ECLiPSe Arrays and Global Variables built-in.|Group Index| Full Index]

getval(+ElemSpec, ?Value)

Succeeds if the visible array element or global variable ElemSpec unifies with the value Value.

+ElemSpec
Atom (global variable) or ground compound term with non negative integer arguments (array element specification).
?Value
Prolog term.

Description

Unifies the copied value of the array element or global variable ElemSpec (visible from the caller module) with Value. If Element is a global reference, its current value is taken, otherwise a copy of the stored term is used.

If ElemSpec is an atom, it must specify a global variable visible from the caller module.

If ElemSpec is a compound term, it must specify a visible array element, all its arguments must be non negative integers smaller than the bounds specified with make_array/1/2 or make_local_array/1/2.

Fail Conditions

Fails if Value does not unify with the value of ElemSpec.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
ElemSpec is not ground.
(5) Type error
ElemSpec is neither an atom nor a structure whose arguments are integers.
(6) Range error
An array index in ElemSpec is out of bounds
(41)
ElemSpec is of an array which does not exist.
(41)
global variable ElemSpec does not exist.

Examples


Success:
      make_array(a(4), real),
          setval(a(2), 2.0),
          getval(a(2), 2.0).
      setval(i, "2"),
          getval(i, V)).   (gives V = "2").

Failure:
      make_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).


See Also

decval / 1, incval / 1, make_array / 1, make_array / 2, make_local_array / 1, make_local_array / 2, setval / 2