Thousands Separators

Graham Samuel livfoss at mac.com
Thu Jul 30 09:51:23 EDT 2015


Very interesting stuff indeed, IMHO. Some time ago I implemented what amounts to a simplified spreadsheet as part of an iOS app. There were cells containing numbers, arithmetic operations on the cells, and displays of the results. It very quickly emerged that every cell had to be stored in two forms: the actual number with the maximum available accuracy; and the display version seen by the user - I called the non-displayed cell the ’shadow’ of the displayed one. It was obvious that any kind of repeated arithmetic on the display version would (and did) result in rounding errors etc which would then show up in the revised displays. In a sense I also adopted Kay’s solution, in that each cell had a property describing its display format (currency, integer, percentage etc). These properties were invoked for every cell involved in an arithmetic operation.

Although this worked pretty well, in fact I abandoned the app after the potential user temporarily lost interest in it: I may well revive it later this year as I know our paths will cross again.

But yet, how great if all this was built into LC.

Graham

> On 30 Jul 2015, at 02:55, Kay C Lan <lan.kc.macmail at gmail.com> wrote:
> 
> On Tue, Jul 28, 2015 at 9:59 PM, Richard Gaskin <ambassador at fourthworld.com>
> wrote:
> 
>> But stepping back to look at the big picture, I find myself wondering:
>> 
>> Why is that even necessary?
>> 
>> Why isn't that just a field property, e.g. "the displayFormat"?
>> 
>> But stepping back further, why would you want it only restricted to a
> field property? What about if I wanted numbers automatically displayed in
> the correct format that came as part of text in an Answer Dialog, or the
> default answer in an Ask Dialog, or even in the Title of one of these or
> the dynamic label of a button, i.e. Option Menu?
> 
> Maybe this is connected with the recent response Mark W gave to the HTML
> <H5> tag bug which has been reclassified as an 'enhancement' request where
> he responded:
> 
> The solution in both cases is not to change the current mappings, but
>> instead to (at some point) make the mappings configurable at runtime. Of
>> course, the rub here is that this causes a global interoperability problem
>> which is not (at this time) clear how to resolve. i.e. In the IDE you could
>> be editing two 'applications' at once both of which want different
>> settings. (Note that keying this at the stack level isn't necessarily
>> correct as stacks can be used as libraries in different contexts - there
>> needs to be some notion of 'project scope' which would arbitrate what
>> mappings were used when).
>> 
> 
> As I said in my response; "in my naivety this sounds like some kind of LC
> CSS is needed."
> 
> Wouldn't it be nice, in one central location to nominate formats, not just
> number, and be able to English like name them for use anywhere (hopefully
> LC would come with a bunch of inbuilt ones).
> 
> set the CSSformat $#,###.00 = "currency"
> set the CSSformat #,### = "wholeThousands"
> set the CSSformat (###) ####-#### = "AreaPhone"
> (possibly grep based)
> set the CSSformat \d{4}-\d{2}-\d{2} \d{2}:\d{2}\d{2} = "SQLDateTime"
> set the CSSformat \d{2} \w{3} \d{2} = "dd mmm yyDate"
> set the CSSformat \w+ at gmail.com = "gmailEmail"
> 
> A stack could then be set to 'wholeThousands'
> 
> use CSSformat "wholeThousands" for this stack
> 
> and then every number, whether field, title or text in an Answer Dialog
> would come up with a thousand separator. If a particular field needed a
> different format, as you say you'd just set it's format property to: use
> CSSFormat  "currency" for fld "price" to override the default.
> 
> It would also be nice to be able to tick a box for a field property that
> automatically invoked data format checking or be able to specify it
> elsewhere.
> 
> --number format assumed to be "currency" because that is the stacks default
> ask question "How much did you spend?" with tValue titled "Lunch
> Expediture" AND formatCheck 1
> 
> --number format different to stack default
> ask question "Which day was the purchase" with tDate useCSSformat "dd mmm
> yyDate" titled "Lunch Expenditure" AND formatCheck 2
> 
> In the LC CSS you'd specify the response for a 1, 2, 3... etc formatCheck
> failure.
> 
> Sitting here dreaming of LC heaven :-)
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list