ex79.pp 458 B

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