How to test for a number

Lynch, Jonathan BNZ2 at CDC.GOV
Wed Mar 16 11:04:17 EST 2005


Hi Klaus...

Heh - the comma brings up another point.

People often separate every third digit before the decimal with a comma!
(not sure how this is done in German)

For example:
1,634,912.34

So commas would need to be allowed, and then replace "," with empty
would need to be used when working with the actual number...

Which could really create a problem in having the program compatable for
both English use and German use!

-----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Klaus
Major
Sent: Wednesday, March 16, 2005 11:00 AM
To: How to use Revolution
Subject: Re: How to test for a number

Hi Jonathan,

> I have a field where I restrict it to only enter numbers...
>
> But I had to include extra script to allow the character to be a "." 
> or a "-", in case the number included a decimal point or minus sign:
>
> On KeyDown theKey
>      If (isNumber(theKey) = true) or theKey = "." or theKey = "-" then

> pass keyDown
> End KeyDown

ah, yes, sure...

But we non english speaking users do have another problem!

We use the "," (Comma) as a decimal separator, so we have to do some 
extra
work before we can compute some values... :-(

If somone is interested, i use these 2 little functions to do the 
conversations before
computing and displaying the result again:

function ohnekomma was
## german for without comma :-)
    replace "," with "." in was
    return was
end ohnekomma

And back:

function mitkomma was
## german for with comma :-)
    replace "." with "," in was
    return was
end ohnekomma

So i can:
...
put mitkomma((ohnekomma(fld 1) * 12)) into fld "result"
...


Or a bit more readable ;-)
...
put ohnekomma(fld 1) into mynumber1
put mynumber * 12 into myresult
put mitkomma(myresult) into fld "result"
...


Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de

_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list