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

incval(+ElemSpec)

Increments the contents of the visible array element or global variable ElemSpec by one.

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

Description

Increments the value of the element ElemSpec that must be of type integer.

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

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
ElemSpec is not instantiated.
(5) Type error
ElemSpec is a structure whose arguments are not all integers.
(5) Type error
ElemSpec is neither an atom nor a ground structure.
(5) Type error
The value or type of ElemSpec is not integer.
(6) Range error
Array index in ElemSpec is out of range.
(41)
ElemSpec is of an array which does not exist.
(41)
global variable ElemSpec does not exist.

Examples


Success:
      [eclipse]: make_array(a(4), prolog),
              setval(a(1), -2),
              incval(a(1)),
              getval(a(1), X).
      X = -1
      yes.

      [eclipse]: make_array(g(4), integer),
              incval(g(1)),
              getval(g(1), X).
      X = 1
      yes.

      [eclipse]: setval(count, 0),
              repeat,
              writeln(hello),
              incval(count),
              getval(count, X),
              X >= 3, !.
      hello
      hello
      hello
      X = 3
      yes.

Error:

      incval(X).                            (Error 4).
      incval(a(2.0)).                       (Error 5).
      setval(a, 2.0), incval(a).            (Error 5).
      make_array(a(2), real),
          incval(a(1)).                     (Error 5).
      make_array(a(10), integer),
          incval(a(-2)).                    (Error 6).
      incval(no_array(0)).                  (Error 41).
      incval(no_var).                       (Error 41).


See Also

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