Page 1 of 1

Formatting Numbers

Posted: Tue Jul 07, 2009 7:53 pm
by phaworth
Got several fields in my database that are currency values. Linking a field on a form to any of them results in just the raw number being displayed, for example 10.0. What I need is for the number to be displayed as $10.00. Some of them will need comma(s) inserted as thousands separators and the formatting also needs to deal with negative values.

Do I have to write my own code to take care of all that or are there built-in functions to take care of it?

Posted: Tue Jul 07, 2009 9:20 pm
by Janschenkel
I'm afraid you'll have to "roll your own" - though you can search the use-revolution list archives to find some past attempts and adapt those to your needs. Here's one of my versions of a numeric field with separators http://article.gmane.org/gmane.comp.ide ... .user/8374, cobbled together from several earlier posts.

Jan Schenkel.

Posted: Tue Jul 07, 2009 9:55 pm
by phaworth
I'm beginning to think Revolution is not for me. I'm impressed with a lot of its functionality but I don't really want to spend hours writing code for really basic things like formatting numbers and being able to pick a date from a calendar grid.

Posted: Tue Jul 07, 2009 10:14 pm
by shadowslash
phaworth wrote:I'm beginning to think Revolution is not for me. I'm impressed with a lot of its functionality but I don't really want to spend hours writing code for really basic things like formatting numbers and being able to pick a date from a calendar grid.
Don't give up now, you'll see once you get used to Rev, you'll notice that you won't need to spend hours writing code for really basic things anymore... Everybody has to start at the bottom right? Image

Posted: Wed Jul 08, 2009 1:01 am
by phaworth
Right, there's always a learning curve, I'd just rather spend it learning how to deal with the logic of my application than on implementing basic formatting like this.

But I'm still trying....
Pete

Posted: Wed Jul 08, 2009 1:27 am
by paul_gr
Look in RevOnline and check out the AccountancyFormat() stack.

Paul

Posted: Wed Jul 08, 2009 1:37 am
by phaworth
Perfect! Thanks.
Pete

Posted: Fri Jul 10, 2009 12:10 am
by whelkybaby
Yay - that stack's my work! Awesome that I've been able to help. :)

Steve

www.theworcestersource.com

Posted: Wed Jul 15, 2009 10:12 pm
by phaworth
Works great, thanks. One question - is there a way to not have any thousands separator? Right now, leaving that field empty inserts a comma.
Pete

Posted: Wed Jul 15, 2009 10:44 pm
by whelkybaby
Easy peasy.

Open up the script and delete this line:

Code: Select all

if pSeparator="" then put "," into pSeparator
Of course, if you want to put a comma in there, you'll now have to enter it as one of the parameters of the function.

Cheers,


Steve

www.theworcestersource.com

Posted: Wed Jul 15, 2009 10:52 pm
by phaworth
Thanks Steve, works great. By the way, nice blog - as a new user of Rev, I need all the reference material I can get. Your tree display is something I had built in to the last dev tool I was using and have been wondering how to deal with it in Rev.
Pete

Posted: Fri Jul 17, 2009 6:35 pm
by whelkybaby
Thanks for the nice comment about the blog!

The tree component isn't far off being finished now. I'm currently in the middle of writing the manual to go with it. I'll probably be stuck indoors this weekend (rain, rain, go away!) and may have a beta by the end of Sunday.

I doubt that finding a few testers won't be too hard!


Steve

www.theworcestersource.com