[ Non-logical Variables, Arrays, Bags, Shelves and Stores | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

# decval(++ElemSpec)

Decrements the contents of the visible non-logical variable or array element ElemSpec by one.

ElemSpec
  Atom or ground compound term whose arguments are non negative integers.

## Description

Decrements by one the value of ElemSpec that must be of type integer.

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

If ElemSpec is a compound term, it must specify an element visible array. All its arguments must be non negative integer smallers than the bound specified with array/1/2 or variable/1.

### Modes and Determinism

- decval(++) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### 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) out of range
  Array index in ElemSpec is out of bounds.
(41) array or global variable does not exist
  ElemSpec does not designate an existing array, variable or reference.

## Examples

    Success:
          [eclipse]: local(array(a(4), prolog)),
                  setval(a(0), -2),
                  decval(a(0)),
                  getval(a(0),X).
          X = -3
          yes.

          [eclipse]: local(array(g(4, 5), integer)),
                  decval(g(3, 2)),
                  getval(g(3, 2), X).
          X = -1
          yes.

          [eclipse]: setval(a, 3),
                  decval(a),
                  getval(a, X).
          X = 2
          yes.

    Error:
          decval(X).                          (Error 4).
          setval(a, 2.0),
              decval(a).                      (Error 5).
          local(array(a(2), float)),
              decval(a(1)).                   (Error 5).
          local(array(a(2))),
              decval(a(2)).                   (Error 6).
          decval(no_var).                     (Error 41).
          decval(noarray(2, 4)).              (Error 41).

## See Also

getval / 2, incval / 1, array / 1, array / 2, variable / 1, setval / 2