Node: Pred, Next: private, Previous: pow, Up: Reference

### Pred

#### Synopsis

         function Pred (i: ordinal_type): ordinal_type;

or

         function Pred (i: ordinal_type; j: Integer): ordinal_type;

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

         function Pred (p: Pointer_type): Pointer_type;

or

         function Pred (p: Pointer_type; j: Integer): Pointer_type;

#### Description

Returns the predecessor of the ordinal_type value `i`, or, if the second argument `j` is given, its `j`th predecessor. For integer values `i`, this is `i - 1` (or `i - j`). (No, `Pred` does not work faster than plain subtraction. Both are optimized the same way, often to a single machine instruction.)

If extended syntax is on, the argument may also be a pointer value. In this case, the address is decremented 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) previous element of the array.

#### Conforming to

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

#### Example

         program PredDemo;

         type
           Metasyntactical = (foo, bar, baz);

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

         begin
           m := Pred (bar);     { foo }
           c := Pred ('Z', 2);  { 'X' }
           a[1] := 42;
           a[4] := Pred (a[1]);     { 41 }
           a[5] := Pred (a[4], 3);  { 38 }
           {$X+}
           p := @a[5];
           p := Pred (p);     { now p points to a[4] }
           p := Pred (p, 3);  { now p points to a[1] }
         end.

#### See also

Succ, Dec, Pointer Arithmetics.