Printing dollar amounts on forms 
Author Message
 Printing dollar amounts on forms

If my user enters 123.4 in a text box, I want it to show $123.40 the
next time the dialog is opened. I've tried searching for how, but I
can't find the answer.

Peaslee



Wed, 07 Apr 2004 04:30:45 GMT  
 Printing dollar amounts on forms


Quote:
> If my user enters 123.4 in a text box, I want it to show $123.40 the
> next time the dialog is opened. I've tried searching for how, but I
> can't find the answer.

There are a few ways this could be done.  One way would be to use a
TypeConverter.  See NumberToText for an example.  Possibly you could create
your own converter to display a number the way you want.  You could also
consider creating your own Currency class and use a corresponding converter
to go back and forth.  Depending upon what you want to do with the number
there may be advantages to using your own Currency class.  One thing to note
is that in order for a TypeConverter subclass to be available as a choice in
the view composer text box typeConverter aspect the class needs to be in the
"MVP-Type Converters*" classification.  If you make this change while a view
composer is open you may need to close it and reopen it to see the new
option.

Hope that helps,

Chris



Wed, 07 Apr 2004 05:36:15 GMT  
 Printing dollar amounts on forms
Chris/Bruce,

A CurrencyToText TypeConverter is the sort of small addition to the Dolphin
image that I had in mind when I added the "Tweaks" page to my web site.
I've therefore implemented it and uploaded it to the site as a stand alone
class - intended for Dolphin 4.01 but I think I will probably work with
earlier versions.

For the Number to Text conversion you can specify the number of characters
to the left and right of the decimal place and ask for the left side to be
padded with either zero or space.

A Text to Number conversion has no formatting rules and answers an Float or
Integer as appropriate.

Thanks for the idea (I hope you don't mind me borrowing it) and if anyone
else has suggestions for small additions like this I would be interested in
hearing about them - no promises though <g>

Ian

http://www.iandb.org.uk



Wed, 07 Apr 2004 18:47:20 GMT  
 Printing dollar amounts on forms
Works like a charm. Decimal currency on the form, a float when I
inspect. Thanks!

It even does the conversion when you tab and the box loses the focus.
That's better than having it change only when you close and reopen the
form. Nice piece of work.

Also, since Smalltalk is open source, anyone can look and see how it's
done and modify it, say, to add commas at the appropriate places.

Peaslee

Quote:

> Chris/Bruce,

> A CurrencyToText TypeConverter is the sort of small addition to the Dolphin
> image that I had in mind when I added the "Tweaks" page to my web site.
> I've therefore implemented it and uploaded it to the site as a stand alone
> class - intended for Dolphin 4.01 but I think I will probably work with
> earlier versions.

> For the Number to Text conversion you can specify the number of characters
> to the left and right of the decimal place and ask for the left side to be
> padded with either zero or space.

> A Text to Number conversion has no formatting rules and answers an Float or
> Integer as appropriate.

> Thanks for the idea (I hope you don't mind me borrowing it) and if anyone
> else has suggestions for small additions like this I would be interested in
> hearing about them - no promises though <g>

> Ian

> http://www.iandb.org.uk



Sat, 10 Apr 2004 00:46:41 GMT  
 Printing dollar amounts on forms
Bruce,

Quote:
> It even does the conversion when you tab and the box loses the focus.
> That's better than having it change only when you close and reopen the
> form. Nice piece of work.

That's down to the underlying dialog behaviour so OA should be the ones
getting the pat on the back for that.

Quote:
> Also, since Smalltalk is open source, anyone can look and see how it's
> done and modify it, say, to add commas at the appropriate places.

I was already going to add a bit to it - truncate to integer only (for cases
when you don't want the dp and fractional part) and also a selectable
currency symbol. I'll add support for commas as well.

Ian



Sat, 10 Apr 2004 18:13:17 GMT  
 Printing dollar amounts on forms

Quote:

> Bruce,

> > It even does the conversion when you tab and the box loses the focus.
> > That's better than having it change only when you close and reopen the
> > form. Nice piece of work.

> That's down to the underlying dialog behaviour so OA should be the ones
> getting the pat on the back for that.

> > Also, since Smalltalk is open source, anyone can look and see how it's
> > done and modify it, say, to add commas at the appropriate places.

> I was already going to add a bit to it - truncate to integer only (for cases
> when you don't want the dp and fractional part) and also a selectable
> currency symbol. I'll add support for commas as well.

> Ian

Is this providing something different to Steve Waring's(?) Currency package?

    another Ian.



Sun, 11 Apr 2004 14:59:43 GMT  
 Printing dollar amounts on forms
Ian,

Quote:
> Is this providing something different to Steve Waring's(?) Currency
> package?

I just had a look through the n/g archive and it was Steve Zara who came up
with a Currency package (which I wasn't aware of!!).

I've just downloaded his package [1] and they do similar jobs but is a
slightly different way, mainly that Steve defines a Currency class based on
ScaledDecimal whereas mine works with normal <number> objects.  I think mine
has a few more formatting options (leading zeros, currency symbol) but
there's not a lot of difference overall.

Thanks for pointing it out - it's good to have different packages available.

Ian

[1] Link on Steve's page at -
http://www.serf.org/steve/Dolphin/



Sun, 11 Apr 2004 16:40:56 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Any help on converting a dollar amount to a written amount, for checks

2. Proper Type for Dollar Amount

3. MySQL query in PHP: Not query zero amounts also removes null amounts from query

4. Check Printing-Dollars to Spanish

5. How to decrease the amount of used memory while printing raport

6. Amount printed as words

7. Printing to a Pre-Printed Form

8. Printing routine for APL+WIN Forms

9. Using pre-printed forms - what approach to take?

10. printing on preprinted forms

11. Printing label without form feed C5b ABC

12. Print single space on form templete

 

 
Powered by phpBB® Forum Software