tb0254.pp 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. { Old file: tbs0294.pp }
  2. { parameter with the same name as function is allowed in tp7/delphi Yes, but in BP this leads to being unable to set the return value ! }
  3. {$mode tp}
  4. { this is allowed in BP !!!
  5. but its complete nonsense because
  6. this code sets parameter test
  7. so the return value can not be set at all !!!!!
  8. of course in Delphi you can use result so there it
  9. makes sense to allow this ! PM }
  10. function test(var test:longint):longint;
  11. var
  12. x : longint;
  13. begin
  14. { in BP the arg is change here !! }
  15. test:=1;
  16. x:=3;
  17. end;
  18. function st(var st : string) : string;
  19. begin
  20. st:='OK';
  21. end;
  22. var t : longint;
  23. myst : string;
  24. begin
  25. t:=2;
  26. myst:='Before';
  27. test(t);
  28. st(myst);
  29. if (t<>1) then
  30. begin
  31. writeln('Test arg in Test function is not handled like in BP');
  32. halt(1);
  33. end;
  34. if (myst<>'OK') then
  35. begin
  36. writeln('St arg in St string function is not handled like in BP');
  37. halt(1);
  38. end;
  39. end.