tprocvar2.pp 517 B

12345678910111213141516171819202122232425262728293031323334353637
  1. {$ifdef fpc}
  2. {$mode tp}
  3. {$endif fpc}
  4. {$F+}
  5. type
  6. tproc = procedure;
  7. tprocx = procedure(x : longint);
  8. const
  9. dummy_call_count : longint = 0;
  10. procedure dummy;
  11. begin
  12. writeln('Dummy called');
  13. inc(dummy_call_count);
  14. end;
  15. procedure dummyx(x : longint);
  16. begin
  17. writeln('Dummy called with x=',x);
  18. inc(dummy_call_count);
  19. end;
  20. var
  21. tp2 : tproc;
  22. tp1x,tp2x : tprocx;
  23. const
  24. tp1 : tproc = dummy;
  25. begin
  26. move(@tp1,@tp2,sizeof(tproc));
  27. tp2;
  28. tp1x:=dummyx;
  29. move(@tp1x,@tp2x,sizeof(tproc));
  30. tp2x(2);
  31. end.