ex21.pp 837 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Program Example21;
  2. { Program to demonstrate the Exit function. }
  3. Procedure DoAnExit (Yes : Boolean);
  4. { This procedure demonstrates the normal Exit }
  5. begin
  6. Writeln ('Hello from DoAnExit !');
  7. If Yes then
  8. begin
  9. Writeln ('Bailing out early.');
  10. exit;
  11. end;
  12. Writeln ('Continuing to the end.');
  13. end;
  14. Function Positive (Which : Integer) : Boolean;
  15. { This function demonstrates the extra FPC feature of Exit :
  16. You can specify a return value for the function }
  17. begin
  18. if Which>0 then
  19. exit (True)
  20. else
  21. exit (False);
  22. end;
  23. begin
  24. { This call will go to the end }
  25. DoAnExit (False);
  26. { This call will bail out early }
  27. DoAnExit (True);
  28. if Positive (-1) then
  29. Writeln ('The compiler is nuts, -1 is not positive.')
  30. else
  31. Writeln ('The compiler is not so bad, -1 seems to be negative.');
  32. end.