Sign in Join

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

Mailing lists / lazarus / 2015-08

whats wrong with that line of code?

12 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

John Landmesser

CurrencyString shows ?

FormatCurr('%M',111111111) -> %M

Expected a currency string as '111.111.111,00 ?'

System: Linux, Debian Sid

sorry for that really idiotic question :-))

Reply by email

John Landmesser
to Michael Van Canneyt

Hi Michael,

sorry, i still don't get it:

Help to FormatFloat tells me:
"FormatFloat formats the floating-point value given by Value using the format specifications in Format."

.. and help to Format:
"M Currency Format ..."

So please correct my,
FormatCurr('%M',111111111)
so i am able to understand my mistakes ...

thank you!

Ok, i'm stupid!!!

Michael Van Canneyt wrote 28 lines
On Sat, 15 Aug 2015, John Landmesser wrote: > CurrencyString shows ? > > FormatCurr('%M',111111111) -> %M > > Expected a currency string as '111.111.111,00 ?' > > System: Linux, Debian Sid > > sorry for that really idiotic question :-)) Why do you think %M is a formatting character ? Valid formatting characters are described at: http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150815/13258a10/attachment.html>

Reply by email

Werner Pamler
to John Landmesser: CurrencyString shows ? FormatCurr('%M',111111111) -> %M Expected a currency string as…

This is how it works with the %m format

procedure TForm1.FormCreate(Sender: TObject);
begin
   DefaultFormatSettings.Currencystring := '?';
   Label1.Caption := Format('%m', [11111111.0]);
   // "Format" instead of "FormatCurr", parameter in square brackets,
value must be a float
end;
John Landmesser wrote 17 lines
CurrencyString shows ? FormatCurr('%M',111111111) -> %M Expected a currency string as '111.111.111,00 ?' System: Linux, Debian Sid sorry for that really idiotic question :-)) -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Werner Pamler
to John Landmesser: sorry, i still don't get it: Help to FormatFloat tells me: "FormatFloat formats the…

As Michael said "%M" is not a format specifier for the FormatCurr function, use "0.00" to get two decimal places . Moreover, as I see in my tests, the currency symbol is not added (because "FormatCurr()" internally calls "FormatFloat()"). I must confess that the docs are quite confusing here...

This should work
   Label2.Caption := FormatCurr('0.00 ?', 111111111.0);
John Landmesser wrote 59 lines
Hi Michael, sorry, i still don't get it: Help to FormatFloat tells me: "FormatFloat formats the floating-point value given by Value using the format specifications in Format." .. and help to Format: "M Currency Format ..." So please correct my, FormatCurr('%M',111111111) so i am able to understand my mistakes ... thank you! Ok, i'm stupid!!! On 15.08.2015 11:40, Michael Van Canneyt wrote: > > > On Sat, 15 Aug 2015, John Landmesser wrote: > >> CurrencyString shows ? >> >> FormatCurr('%M',111111111) -> %M >> >> Expected a currency string as '111.111.111,00 ?' >> >> System: Linux, Debian Sid >> >> sorry for that really idiotic question :-)) > > Why do you think %M is a formatting character ? > > Valid formatting characters are described at: > > http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html > > Michael. > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150815/ea7ceb90/attachment.html>

Reply by email

Michael Van Canneyt
to John Landmesser: sorry, i still don't get it: Help to FormatFloat tells me: "FormatFloat formats the…
John Landmesser wrote 10 lines
Hi Michael, sorry, i still don't get it: Help to FormatFloat tells me: "FormatFloat formats the floating-point value given by Value using the format specifications in Format." From the help:

"FormatCurr formats the currency Value according to the formatting rule in Format, and returns the resulting string."

here <Format> refers to the parameter format, not the function, as you seemed to surmise.

Yet the next sentence in Help
"For an explanation of the formatting characters, see FormatFloat. "

Should have given you a clue.

Well, I have adapted the text so it is less ambiguous.

Werner has given you a example of what to code.

Michael.

Reply by email

Graeme Geldenhuys
to Werner Pamler: As Michael said "%M" is not a format specifier for the FormatCurr function, use "0.00" to…
Werner Pamler wrote
I must confess that the docs are quite confusing here...

And here is a LateX issue in the docs for Format()

Under the "M" currency format text it shows:

Currency format. the next argument in the var{Args} array

The LaTeX "var{...}" is shown literally, instead of converted to Italic text. @Michael: Must I file a bug report, or will you make a note about it?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys: To add to that, CurrencyFormat() shows in the docs as "deprecated", but it doesn't…
Graeme Geldenhuys wrote 8 lines
On 2015-08-15 11:24, Werner Pamler wrote: > I must confess that the docs are > quite confusing here... To add to that, CurrencyFormat() shows in the docs as "deprecated", but it doesn't suggest a function that replaces it. http://www.freepascal.org/docs-html/rtl/sysutils/currencyformat.html

It will in 3.0:

http://www.freepascal.org/docs-html-3.0.0/rtl/sysutils/currencystring.html

Michael.

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys: And here is a LateX issue in the docs for Format() Under the "M" currency format text it…
Graeme Geldenhuys wrote 14 lines
On 2015-08-15 11:24, Werner Pamler wrote: > I must confess that the docs are > quite confusing here... And here is a LateX issue in the docs for Format() Under the "M" currency format text it shows: Currency format. the next argument in the var{Args} array The LaTeX "var{...}" is shown literally, instead of converted to Italic text. @Michael: Must I file a bug report, or will you make a note about it?

Already done.

Michael.

Reply by email

John Landmesser
to Werner Pamler: This is how it works with the %m format procedure TForm1.FormCreate(Sender: TObject);…

A) thank you guys!!!

B) Werner Pamler ...

Fazit: ... so its not possible to get the currency symbol ? using FormatCurr, that what i learned so far?!!

i was wrong interpreting the function name as delivering a formatted number plus(!!) the currency symbol!

Werner Pamler wrote 35 lines
This is how it works with the %m format procedure TForm1.FormCreate(Sender: TObject); begin DefaultFormatSettings.Currencystring := '?'; Label1.Caption := Format('%m', [11111111.0]); // "Format" instead of "FormatCurr", parameter in square brackets, value must be a float end; Am 15.08.2015 um 11:13 schrieb John Landmesser: > CurrencyString shows ? > > FormatCurr('%M',111111111) -> %M > > Expected a currency string as '111.111.111,00 ?' > > System: Linux, Debian Sid > > sorry for that really idiotic question :-)) > > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sven Barth
to John Landmesser
"John Landmesser" wrote
i was wrong interpreting the function name as delivering a formatted

number plus(!!) the currency symbol!

Because there might be cases in which you don't want the currency symbol. And better to manually add something than to remove something ;)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150815/9175bf6f/attachment.html>

Reply by email