bug0205.pp 800 B

12345678910111213141516171819202122232425262728293031
  1. program bug_show;
  2. { By PAV ([email protected]) }
  3. function bad_uppercase(s:string):string;
  4. var i:integer;
  5. begin
  6. for i:=1 to length(s) do
  7. if (ord(s[i])>=97 and ord(s[i])<=122) then s[i]:=chr(ord(s[i])-97+65);
  8. bad_uppercase:=s;
  9. end;
  10. function good_uppercase(s:string):string;
  11. var i:integer;
  12. begin
  13. for i:=1 to length(s) do
  14. if (ord(s[i])>=97) and (ord(s[i])<=122) then s[i]:=chr(ord(s[i])-97+65);
  15. good_uppercase:=s;
  16. end;
  17. const cadena='Free Paskal Compiler 0.99.8 !!! (bug)';
  18. begin
  19. writeln('This is the original string before convert it');
  20. writeln(cadena);
  21. writeln();
  22. writeln('This is a bad result, using "if ( and )"');
  23. writeln(bad_uppercase(cadena));
  24. writeln();
  25. writeln('This is a good result, using "if () and ()"');
  26. writeln(good_uppercase(cadena));
  27. writeln();
  28. end.