Currency and percentage in numeric evaluation
Richard Gaskin
ambassador at fourthworld.com
Mon Apr 11 14:07:14 EDT 2005
Robert Presender wrote:
> On Apr 10, 2005, at 9:00 AM, Richard Gaskin wrote:
>
>> I need to evaluate a large number of short strings to
>> determine whether they are numeric. Some of these are
>> percentages, and include the "%", and others are
>> currency and can contain "$". the Euro, Yen, or any
>> number of other signs.
>>
>> With dates we have a convenient test: try to convert
>> it, and if it fails it will tell you why.
>>
>> But we have no such convenience with percentages and
>> currency. So what is the most efficient (heck, I'd
>> settle for reasonable efficient) way to determine if
>> a string is numeric given the wide range of currency
>> formats in common use?
>
> I put the following into the msg box
>
> put "12%" into holder
> put holder is a number
>
> The above returns returns false
Precisely the problem: in the context of my application (in which
numeric comparisons are done with monetary and percentage values in
addition to raw numbers) "12%" needs to be treated as a number.
In lieu of any consistently reliable way to determine if a string may be
a monetary amount, I've opted for the user to be able to specify if a
given field should be treated as such. While I'd rather have that done
automatically, it's more important that I remove all ambiguity in order
to do a proper comparison.
Thanks for all the input in this.
--
Richard Gaskin
Fourth World Media Corporation
Developer of WebMerge: Publish any database on any Web site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list