• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Check if it is a number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check if it is a number


  • Subject: Re: Check if it is a number
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Tue, 03 Dec 2002 10:16:58 -0500

> Subject: Re: Check if it is a number
> Date: Tue, 3 Dec 2002 13:41:58 +0000
> From: Nigel Garvey <email@hidden>

>>> From: Paul Skinner <email@hidden>

>>> NumeralsOnly("12A4B5")-->false

>>> on NumeralsOnly(n)
>>> try
>>> n as number
>>> return n does not contain "-" and n does not contain "+" and n does
>>> not contain " " and n is not ""
>>> on error
>>> return false
>>> end try

> ... It needs one more test if it's to exclude the decimal point
> character - but then it may not be meant to.

> 3) The above notwithstanding, if testing for a decimal point isn't
> important, here's another fast variation on Paul's handler:

> on NumeralsOnly(n)
> try
> n as number
> return (count n) = (count n's first word)
> on error
> return false
> end try
> end NumeralsOnly

Great stuff Nigel, but one problem:

NumeralsOnly("+") --> true


{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.

  • Prev by Date: "/" problems
  • Next by Date: Re: Check if it is a number
  • Previous by thread: Re: Check if it is a number
  • Next by thread: Re: Check if it is a number
  • Index(es):
    • Date
    • Thread