Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-05

Decimal dot

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

Hello,
I need to log some real values so I write them to a file. Unfortunately the real's are in the form of xxx.yyy, mark the dot. If I try to import that file in OOo Calc, on the same PC, I get text-values instead of numbers. If I substitue the dots by comma's I get number-values and I can make graphs.
Am I doing something wrong that fpc writes decimal dots and OOo expects comma's ? I think it's something to do with locales but I don't know where to look to configure things.
Using fpc 2.2.0 on Linux, Suse 10.3 if that matters, and also on a "homebrew" LFS-machine (LFS=linux from scratch).

Thanks,
Koenraad Lelong.

Koenraad Lelong
to Michael Van Canneyt: You need to set the DecimalSeparator character (to ',' in your case) , and format your…
Michael Van Canneyt wrote 22 lines
On Thu, 8 May 2008, Koenraad Lelong wrote: > Hello, > I need to log some real values so I write them to a file. Unfortunately > the real's are in the form of xxx.yyy, mark the dot. If I try to import > that file in OOo Calc, on the same PC, I get text-values instead of > numbers. If I substitue the dots by comma's I get number-values and I > can make graphs. > Am I doing something wrong that fpc writes decimal dots and OOo expects > comma's ? I think it's something to do with locales but I don't know > where to look to configure things. You need to set the DecimalSeparator character (to ',' in your case) , and format your floats with floattostr or one of the other formatting routines in sysutils. The system unit routines always use '.' as a decimal separator. If you don't want to use the sysutils routines, use Str() to convert to a string, and replace the dot with a comma in the resulting string. Michael.

Thanks, good to know that.
Koenraad.

Michael Van Canneyt
to Koenraad Lelong: I need to log some real values so I write them to a file. Unfortunately the real's are in…
Koenraad Lelong wrote 9 lines
Hello, I need to log some real values so I write them to a file. Unfortunately the real's are in the form of xxx.yyy, mark the dot. If I try to import that file in OOo Calc, on the same PC, I get text-values instead of numbers. If I substitue the dots by comma's I get number-values and I can make graphs. Am I doing something wrong that fpc writes decimal dots and OOo expects comma's ? I think it's something to do with locales but I don't know where to look to configure things.

You need to set the DecimalSeparator character (to ',' in your case) , and format your floats with floattostr or one of the other formatting routines in sysutils.

The system unit routines always use '.' as a decimal separator. If you don't want to use the sysutils routines, use Str() to convert to a string, and replace the dot with a comma in the resulting string.

Michael.

Felipe Monteiro de Carvalho
to Koenraad Lelong: Thanks, good to know that. Koenraad.

There is fpspreadsheet, a library you can use to output the file in Excel format (which OO.org should be able to read):

http://wiki.lazarus.freepascal.org/FPSpreadsheet

In there wiki there is a very old (but working) code to write Excel 2 files. The current fpSpreadsheet code is much more advanced and supports several Excel versions with some experiemental work for OOXML and ODS. It is now object-oriented and modular.

A Toolbox article and a general update in the wiki doc are planned for the near future.

Felipe Monteiro de Carvalho