Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Graeme Geldenhuys
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


Regards,
  - Graeme -

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Michael Van Canneyt



On Sat, 15 Aug 2015, Graeme Geldenhuys wrote:


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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread John Landmesser

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!




On 15.08.2015 12:12, Werner Pamler wrote:

This is how it works with the %m format

procedure TForm1.FormCreate(Sender: TObject);
begin
  DefaultFormatSettings.Currencystring := '€';
  Label1.Caption := Format('%m', [.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',1) - %M

Expected a currency string as '111.111.111,00 €'

System: Linux, Debian Sid

sorry for that really idiotic question :-))



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] whats wrong with that line of code?

2015-08-15 Thread John Landmesser

CurrencyString shows €

FormatCurr('%M',1) - %M

Expected a currency string as '111.111.111,00 €'

System: Linux, Debian Sid

sorry for that really idiotic question :-))



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Michael Van Canneyt



On Sat, 15 Aug 2015, John Landmesser wrote:


CurrencyString shows €

FormatCurr('%M',1) - %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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread John Landmesser

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',1)
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',1) - %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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Werner Pamler
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 €', 1.0);


Am 15.08.2015 um 12:11 schrieb John Landmesser:

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',1)
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',1) - %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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Michael Van Canneyt



On Sat, 15 Aug 2015, John Landmesser wrote:


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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Michael Van Canneyt



On Sat, 15 Aug 2015, Graeme Geldenhuys wrote:


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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Werner Pamler

This is how it works with the %m format

procedure TForm1.FormCreate(Sender: TObject);
begin
  DefaultFormatSettings.Currencystring := '€';
  Label1.Caption := Format('%m', [.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',1) - %M

Expected a currency string as '111.111.111,00 €'

System: Linux, Debian Sid

sorry for that really idiotic question :-))



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Graeme Geldenhuys
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?


Regards,
  - Graeme -

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] whats wrong with that line of code?

2015-08-15 Thread Sven Barth
Am 15.08.2015 13:19 schrieb John Landmesser jmlandmes...@gmx.de:
 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
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus