* * *

Author Topic: Accountancy format of 'Floats'  (Read 2450 times)

jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #15 on: January 11, 2017, 10:04:37 am »
I already have the jujiboutils package and have looked at the offerings there but all the FloatEdit components have a label which can't be hidden so totally useless for this application.

To hide the label in code:

Code: Pascal  [Select]
  1. JLabeledFloatEdit1.EditLabel.Visible:= False;

To hide the label in design mode, simply type a blank space in property editor (Editlabel->Caption)

To read and set values, use the property Value:

Code: Pascal  [Select]
  1. JLabeledFloatEdit1.Value:= 10.5;
  2. f:= JLabeledFloatEdit2.Value;  

J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #16 on: January 11, 2017, 12:28:29 pm »
To hide the label in code:
Code: Pascal  [Select]
  1. JLabeledFloatEdit1.EditLabel.Visible:= False;
To hide the label in design mode, simply type a blank space in property editor (Editlabel->Caption)
Thanks for your input jujibo.
I thought I'd tried all the possibilities but not that one - yes it removes the Label
Quote from: jujibo
To read and set values, use the property Value:
Code: Pascal  [Select]
  1. JLabeledFloatEdit1.Value:= 10.5;
  2. f:= JLabeledFloatEdit2.Value;  
At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.

This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 ... but Molly has addressed that very effectively  (even though I'm still working on the 'Understanding' of that code  :D )

jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #17 on: January 11, 2017, 12:57:55 pm »
At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.
:D )

Yes, Value property is available at design time (see attached image).

This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 ... but Molly has addressed that very effectively  (even though I'm still working on the 'Understanding' of that code  :D )

Do you want to display negative numbers like "(20)" for -20? or you really want to type (20) and being translated to -20?  For the first case would be easy to implement a new display property for negative numbers. For the second case, I don't see the utility but could be managed too.


jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #18 on: January 11, 2017, 01:40:05 pm »

At design time it seems that there is no 'Value'  property so it cannot be set to 0.00 and although I've set the 'Decimals' to 2 and the DisplayFormat to '9999.99' or '####.##' , at run time, the display is [    nil] and although the component takes focus, it doesn't take keyboard entry. I've tried both FloatEdit and CurrencyEdit.
:D )

Are you sure you are using non DB components?  JLabeledFloatEdit instead of TJDBLabeledFloatEdit?

JujiboDB palette  components are DB Aware components.
We are talking about Jujibo palette components (non DB).

J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #19 on: January 11, 2017, 01:44:12 pm »
At design time it seems that there is no 'Value'  property
Yes, Value property is available at design time (see attached image).
Apologies, jujibo,  I had inadvertantly selected from the DB Version. Now I've checked the 'normal' package the components do work as expected and I can set the default value to 0.00.
Quote from: jujibo
Quote from: J-G
This is all very interesting for potential future development but it doesn't actually address the issue of taking the string (20.00) and converting it to the value -20 )

Do you want to display negative numbers like "(20)" for -20? or you really want to type (20) and being translated to -20?  For the first case would be easy to implement a new display property for negative numbers. For the second case, I don't see the utility but could be managed too.

The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned.

 

jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #20 on: January 11, 2017, 01:54:17 pm »
Quote from: J-G
The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned. 

Well, I can implement two properties:

NegativeDisplayFormat (if empty it usesDisplayformat)
NegativeFontColor

About the gap because the parenthesis is not so easy... probably adding a space to DisplayFormat may be enough

Does this fit your needs?



J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #21 on: January 11, 2017, 02:32:19 pm »
Quote from: J-G
The first case is exactly what I would like - and if the colour could also be set to red that would also be useful. There would be a small matter of display alignment since the trailing bracket should protrude beyond the 'pence' to keep the decimal point aligned. 

Well, I can implement two properties:

NegativeDisplayFormat (if empty it usesDisplayformat)
NegativeFontColor

About the gap because the parenthesis is not so easy... probably adding a space to DisplayFormat may be enough

Does this fit your needs?
Mostly yes. 

The position could be left to the programmer - it would be a matter of setting the 'width' property of the component dependent upon the value being negative. That way the amount of 'shift' could be set in pixels rather than characters. It might be useful to make mention of this in the hints when the NegativeDisplayFormat is active.

The major issue I see is that taking a StrToFloat when the brackets are present should not be an error and I doubt that that is within your control and would still need a new version of StrToFloat.


jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #22 on: January 11, 2017, 06:13:23 pm »
I have implemented in JLabeledCurrencyEdit  (just for testing)

Property: NegativeDisplayFormat
Property: NegativeColor

You can get it in latest lazarus-ccr svn code (rev 5629) . Get, compile and install.

Example to use it:

New Application. Drop two JLabeledCurrencyEdit components in the form.
Set DisplayFormat to: #,0.00€
Set NegativeDisplayFormat to:  (#,0.00)€
Set NegativeColor to: clRed
Set Alignment to: taRightJustify

Run the program. It will display 0.00€
type -5 after updated it will display in red: (5.00)€

You also can change default font color.

As you can see, there is no need for special StrToFloat.  :)

J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #23 on: January 11, 2017, 07:19:46 pm »
You can get it in latest lazarus-ccr svn code (rev 5629) . Get, compile and install.

As you can see, there is no need for special StrToFloat.  :)   

That looks to be a result  :)

Only problem I have is that I have no idea how to 'Get' rev 5629

molly

  • Hero Member
  • *****
  • Posts: 1561
Re: Accountancy format of 'Floats'
« Reply #24 on: January 11, 2017, 08:11:27 pm »
Only problem I have is that I have no idea how to 'Get' rev 5629
In case not using svn, you can point your browser to lazarus ccr svn on sourceforge, then press the link "download snapshot" which will let sf generate a zip file for you which includes the latest (my time of writing that was rev. 5630).

fwiw:having a separate component is/was another option that would help your case the best way possible (i' just did not had the time to do it myself, so thank you very much jujibo).

J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #25 on: January 11, 2017, 09:09:06 pm »
Only problem I have is that I have no idea how to 'Get' rev 5629
In case not using svn, you can point your browser to lazarus ccr svn on sourceforge, then press the link "download snapshot" which will let sf generate a zip file for you which includes the latest (my time of writing that was rev. 5630).

fwiw:having a separate component is/was another option that would help your case the best way possible (i' just did not had the time to do it myself, so thank you very much jujibo).

Thanks Molly.  That partially moves me forward but I'm now a little confused. (It's my age you know  ::)  )

I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)

jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #26 on: January 11, 2017, 09:22:06 pm »
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.
Am I being a 'wuss' ?? :)

Sorry. I'll revert part of the commit.

The negative number display format was working in the earlier version (the version you had).

You only have to set the negative format as explained in the docs: http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html    positiveformat;negativeformat;zeroformat

In this case, set DisplayFormat to: #,0.00€;(#,0.00)€
 :D

I'll modify all the components to allow custom color for negative values.


molly

  • Hero Member
  • *****
  • Posts: 1561
Re: Accountancy format of 'Floats'
« Reply #27 on: January 11, 2017, 09:35:48 pm »
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)
Either you know what version control does or you don't. Nothing "wuss" about that  :)

In case you have a svn client installed on your computer, you literally have a set of (commandline-)tools that allow you to download specific portions of the source-tree.

By downloading a snapshot, you've literally downloaded the complete source-tree. This includes all those other components that are present in the lazasrus ccr (and that are probably of no direct interest for you).

So, that makes up for the (relative) ridiculous huge size of the zip file (in case you only require jujibo's changes) :-)

The trick here is to extract only those portion from the zp file that you are interested in.

In case of jujiboutils, you can do with only extracting the folder lazarus-ccr-svn-5630\components\jujiboutils from the zip file and install the component from that sources, as any other package./component (at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).

jujibo

  • Jr. Member
  • **
  • Posts: 59
Re: Accountancy format of 'Floats'
« Reply #28 on: January 11, 2017, 09:49:08 pm »
...(at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).

No Molly, your indications are ok  :).  I mean one of the new added properties is not needed because the functionality was there. I'll remove NegativeDisplayFormat property.


J-G

  • Sr. Member
  • ****
  • Posts: 285
Re: Accountancy format of 'Floats'
« Reply #29 on: January 11, 2017, 10:00:01 pm »
I am downloading the snapshot but I was anticipating an update to the jujiboutils package which I could simply add to my existing installation of Laz 1.6 whereas I feel that I will have a new version of Lazarus.

Am I being a 'wuss' ?? :)
Either you know what version control does or you don't. Nothing "wuss" about that  :)
Ah - a kindred spirit :)   even though I might feel like a wuss.

I often tell people "the only silly question is one that you already know the answer to"
Quote from: molly
In case you have a svn client installed on your computer, you literally have a set of (commandline-)tools that allow you to download specific portions of the source-tree.

By downloading a snapshot, you've literally downloaded the complete source-tree. This includes all those other components that are present in the lazasrus ccr (and that are probably of no direct interest for you).
Once I'd unzipped the download I could better see what I had and now have an understanding of the concept of version control.

I actually do have Tortoise installed but I've only used it once at the behest of lainz so I could have fired that up - if I had functioning grey-matter  :)

Quote from: molly
In case of jujiboutils, you can do with only extracting the folder lazarus-ccr-svn-5630\components\jujiboutils from the zip file and install the component from that sources, as any other package./component

I've found the jujiboutils folder so can simply re-add that package which I think will just over-write the existing version.

Quote from: molly
(at least it should. I am a bit confused about jujibo's reaction as that would indicate my directions won't work ?).
I've re-read jujibo's reaction (and the second response) and suspect that the version I now have may not be the best. Since there is no time pressure, I think my best bet is to wait 'til tomorrow and download again.


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus