Re: Check if it is a number
Re: Check if it is a number
- Subject: Re: Check if it is a number
- From: Nigel Garvey <email@hidden>
- Date: Fri, 6 Dec 2002 00:53:43 +0000
has wrote on Thu, 5 Dec 2002 15:35:00 +0000:
>
Nigel Garvey wrote:
>
>
> on NumeralsOnly(n)
>
> try
>
> n as number
>
> return result as string is n and result >= 0
>
> on error
>
> return false
>
> end try
>
> end NumeralsOnly
>
>
>
Even a very quick poke at the above reveals a bunch of faulty and/or
>
inconsistent cases and susceptibility to outside influences:
>
>
NumeralsOnly("1000000000")
>
NumeralsOnly("001")
Oh dear. Apologies yet again. My heart's obviously not in it at the
moment. Too much going on in real life to give numbers in strings the
interest and attention they deserve. :-( Also...
>
I'd suggest the following approach:
>
1. work out what values will and won't be regarded as valid
>
2. compose a comprehensive set of test cases [1]
>
3. write a version that works reliably (speed be damned)
>
4. mess around with optimisations/clever hacks last.
... I'm particularly not interested in having has get on my tits - either
on list or off - nearly every post I make, so I think I'll bow out for a
while. I hope to contribute again when I'm back up to speed personally -
or when I need help with Mac OS X!
Best wishes to all.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.