It's actually stickier than that, depending on how far and wide your currency must be displayed...

Currency can be 1-3 characters ($ or GBP, if you see what I mean)...and many of the single letter currency symbols require unicode...take the euro "€" for example. On windows it's alt-0128 (on the keypad).

The thousands separator is '.' in the US, but it's ',' in many parts of the world (Europe).

The decimal separator seems to always be the opposite of the thousands separator (if the TS is ',', then the decimal is '.').

And how is it formatted if the number goes negative?  (1234.00)?  -1234.56?

I'd probably try something regexpy here...let's see...

Anyway, if you're talking just the US, how about:

put 12345.67 into q
put "" into retval

-- watch out for the wrap here in email...
-- this regexp is meant to be together on one long line.
if matchText(q,"([0-9]{0,3}?)([0-9]{0,3}?)([0-9]{0,3}?)([0-9]{0,3}?)\.([0-9]{0,2})$",db,dm,dt,du,dc) then
  put db&comma&dm&comma&dt&comma&du&"."&dc into tmp
  put matchText(tmp,",*(.*)",retval) into junk
  put "$"&retval into retval
end if

I'm sure there's a smarter way to do it, but that's a quick approach.

-Ken

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to