[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'System' (#rtl)

# Setjmp

Save current execution point.

## Declaration

Source position: setjumph.inc line 26

`function Setjmp(`
`var S: jmp_buf`
`):LongInt;`

## Description

SetJmp fills env with the necessary data for a jump back to the point where it was called. It returns zero if called in this way. If the function returns nonzero, then it means that a call to LongJmp with env as an argument was made somewhere in the program.

## Errors

None.

## See also

LongJmp |  | Jump to address.

## Example

    program example79;

    { Program to demonstrate the setjmp, longjmp functions }

    procedure dojmp(var env : jmp_buf; value : longint);

    begin
      value:=2;
      Writeln ('Going to jump !');
      { This will return to the setjmp call,
        and return value instead of 0 }
      longjmp(env,value);
    end;

    var env : jmp_buf;

    begin
      if setjmp(env)=0 then
        begin
        writeln ('Passed first time.');
        dojmp(env,2);
        end
      else
        writeln ('Passed second time.');
    end.

Documentation generated on: May 14 2021