tb0364.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. uses
  2. sysutils;
  3. { comment by submitter:
  4. The following statement (which works in Delphi)
  5. result:=Format('%10.n', [ival*1.0]);
  6. generated an unhandled exception (and said: Missing argument in format "").
  7. Checking the Delphi documentation, it agrees with the fpc documentation
  8. (units.pdf), that a dot should be followed by a <prec> (but Delphi does
  9. not appear to explicitly state that prec should be an integer).
  10. It appears that Delphi is treating this like %10.0n, although it is
  11. potentially undefined behaviour. The fpc documentation indicates I
  12. should get an EConversionError exception if there are problems.
  13. (Actually the documentation may be inconsistent, since it also says
  14. I may get an EConvertError exception.)
  15. If I change the format string to %10.0n, the program runs OK using
  16. fpc, however, my thousand separators do not appear.
  17. }
  18. var
  19. s : string;
  20. ival : integer;
  21. begin
  22. ThousandSeparator:='.';
  23. DecimalSeparator:=',';
  24. ival:=1234;
  25. s:=Format('%10.n', [ival*1.0]);
  26. writeln('s: "',s,'"');
  27. if s<>' 1.234' then
  28. begin
  29. writeln('Problem with Format');
  30. halt(1);
  31. end;
  32. end.