THNumberFormatter

Here is where the magnanimous folks that create externals post them (.zip archives only please).

THNumberFormatter

Postby sctell » Mon Jul 16, 2012 6:24 am

I am in the process of preparing a chart external and while coding part of which uses NSNumberFormatter it crossed my mind that an external with number formatting capability would be good for SC.

Here it is, THNumberFormatter is a minimal external that uses NSNumberFormatter's setFormat function to return a formatted number to SC.
Here is a simple explanation:

NOTES:

A string that can consist of one, two, or three parts separated by “;”. The first part of the string represents the positive format, the second part of the string represents the zero value, and the last part of the string represents the negative format. If the string has just two parts, the first one becomes the positive format, and the second one becomes the negative format. If the string has just one part, it becomes the positive format, and default formats are provided for zero and negative values based on the positive format.

// specify just positive format

$#,##0.00

// specify positive and negative formats

$#,##0.00;($#,##0.00)

// specify positive, zero, and negative formats

$#,###.00;0.00;($#,##0.00)


All the best

Terry


THNumberFormatterTest.zip
(18.48 KiB) Downloaded 195 times
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THNumberFormatter

Postby codegreen » Mon Jul 16, 2012 4:43 pm

sctell wrote:it crossed my mind that an external with number formatting capability would be good for SC.

Why yes, that sounds like an excellent idea! Maybe like the formatNum XFcn in Xtend?

:P
-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: THNumberFormatter

Postby sctell » Mon Jul 16, 2012 11:12 pm

codegreen wrote:Why yes, that sounds like an excellent idea! Maybe like the formatNum XFcn in Xtend?


Ah well, choice is a good thing :lol:

No harm done, it only took 10 minutes.

sctell wrote:I am in the process of preparing a chart external


Before I go any further have you got a Charting external that's hiding away somewhere ;)


All the best

Terry
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THNumberFormatter

Postby codegreen » Tue Jul 17, 2012 6:50 am

sctell wrote:No harm done, it only took 10 minutes.

Which just goes to show the difference between Carbon and Cocoa: Cocoa hides complexity so much better! In Carbon it probably would've taken you days to figure out how to get this all working properly (it's one of the more notoriously gruesome areas of internationalization, with only an 'expert' mode...).

sctell wrote:I am in the process of preparing a chart external

Before I go any further have you got a Charting external that's hiding away somewhere ;)

Nope, AFAIK you're the undisputed mayor of Chartville... :)

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm


Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest

cron