I use a function whose name I stole from VBScript:
function FormatCurrency data
#- function FormatCurrency data
# given a number in data, return it as money
if not isNumber(data) then return "0.00"
else return format("%4.2f", data)
end FormatCurrency
Now, it does nothing about the "$" prefix, which if absolutely necessary would need implementation in something like the following abominable manner. In apps like Excel, the "$" in cells are not part of the data. Rather they are part of the metadata of a cell, which means that something similar would need to be reflected in MetaCard. Among the 2 options are to store the data in one (hidden) metadata field and to display the "pretty" version of it in another. This means building a 2-field management subsystem. The hidden metadata field would keep a totally different version of the data, for instance,
cellH:A
cellV:1
rect:25,50,65,80
val:25.50
prefix:$
name:Net Sales
The coordinates are useful because the first point of entry for Excel calculation is the enter event, triggered by mouse actions, keyboard events, or programmatically. With mouse events, the mouseLoc is detected and then resolved to a cell by a numerical formula (even in the case of spreadsheets whose cells are not all of the same size, because of row and/or column resizing). If you'd prefer not to design a geo-location algorithm of this sort, you can instead put the H & V values of the cell and/or the cell's rectangle in the metadata, as shown above. The point is that the amount of metadata you want to put in is up to you. From early Excel implementations, there was the ability to use calculated compound cell references, whereby the value of the current cell is determined by some formula using other cel!
ls. This was nice until the first problem was discovered: circularity of reference. This led to the creation of a large amount of defensive code for the detection of circular references, and you probably don't want to go there. But this is at least one stab at the currency problem, and although probably much more than you wanted, it at least provides some context of the possibilities and commitments that stand in the way of the "$" for numerical calculation.
Cheers.
Gregory Lypny <[EMAIL PROTECTED]> wrote:
Hi,
Is it possible to use MC's numberFormat function to display numbers
in currency format, e.g., $23.87?
Greg
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.
Francisco J. Ricardo, Ph.D.
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone with Yahoo! by Phone.
