[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 9.271 Succ

### Synopsis

    function Succ (i: ordinal type): ordinal type;

or

    function Succ (i: ordinal type; j: Integer): ordinal type;

or, with extended syntax (``--extended-syntax'` or ``{$X+}'`),

    function Succ (p: Pointer type): Pointer type;

or

    function Succ (p: Pointer type; j: Integer): Pointer type;

### Description

Returns the successor of the ordinal type value ``i'`, or, if the second argument ``j'` is given, its ``j'`th successor. For integer values ``i'`, this is ``i + 1'` (or ``i + j'`). (No, ``Succ'` does not work faster than plain addition. Both are optimized to a single machine instruction or even expanded by the compiler, if possible.)

If extended syntax is on, the argument may also be a pointer value. In this case, the address is incremented by the size of the variable pointed to, or, if ``j'` is given, by ``j'` times the size of the variable pointed to. If ``p'` points to an element of an array, the returned pointer will point to the (``j'`th) next element of the array.

### Conforming to

The ``Succ'` function is defined in ISO-7185 Pascal. The optional second parameter is defined in ISO-10206 Extended Pascal. Application of ``Succ'` to pointers is defined in Borland Pascal. The combination of the second argument with application to pointers is a GNU extension.

### Example

    program SuccDemo;

    type
      Metasyntactical = (foo, bar, baz);

    var
      m: Metasyntactical;
      c: Char;
      a: array [1 .. 7] of Integer;
      p: ^Integer;

    begin
      m := Succ (foo);     { bar }
      c := Succ ('A', 4);  { 'E' }
      a[1] := 42;
      a[2] := Succ (a[1]);     { 43 }
      a[5] := Succ (a[2], 7);  { 50 }
      {$X+}
      p := @a[1];
      p := Succ (p);     { points to `a[2]' now }
      p := Succ (p, 3);  { points to `a[5]' now }
    end.

### See also

section 9.201 Pred, section 9.115 Inc, section 8.6 Pointer Arithmetics.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html