home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / refex / ex79.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  458 b   |  26 lines

  1. program example79;
  2.  
  3. { Program to demonstrate the setjmp, longjmp functions }
  4.  
  5. procedure dojmp(var env : jmp_buf; value : longint);
  6.  
  7. begin
  8.   value:=2;
  9.   Writeln ('Going to jump !');
  10.   { This will return to the setjmp call, 
  11.     and return value instead of 0 }
  12.   longjmp(env,value);
  13. end;
  14.  
  15. var env : jmp_buf;
  16.  
  17. begin
  18.   if setjmp(env)=0 then
  19.     begin
  20.     writeln ('Passed first time.');
  21.     dojmp(env,2);
  22.     end
  23.   else
  24.     writeln ('Passed second time.');
  25. end.
  26.