ex91.pp 647 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Program Example91;
  2. { This program demonstrates the TextToFloat function }
  3. {$mode objfpc}
  4. {$h+ }
  5. Uses SysUtils;
  6. Const
  7. NrValues = 5;
  8. TestStr : Array[1..NrValues] of pchar =
  9. ('1,1','-0,2','1,2E-4','0','1E4');
  10. Procedure Testit;
  11. Var
  12. I : Integer;
  13. E : Extended;
  14. begin
  15. Writeln('Using DecimalSeparator : ',DecimalSeparator);
  16. For I:=1 to NrValues do
  17. begin
  18. Writeln('Converting : ',TestStr[i]);
  19. If TextToFloat(TestStr[i],E) then
  20. Writeln('Converted value : ',E)
  21. else
  22. Writeln('Unable to convert value.');
  23. end;
  24. end;
  25. Begin
  26. DecimalSeparator:=',';
  27. Testit;
  28. DecimalSeparator:='.';
  29. Testit;
  30. End.