• 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: Paul Skinner <email@hidden>
  • Date: Fri, 6 Dec 2002 08:49:08 -0500

On Friday, December 6, 2002, at 01:18 AM, Marc S.A. Glasgow wrote:

How about:

on NumeralsOnly(n)
try
return (0=n-n) as boolean
-- or return n if prefered
on error
return false as boolean
end try
end NumeralsOnly


I haven't speed checked it, but it seems simpler in executable steps than the offered handler.
=-= Marc

It's faster by far in every test. But that's because it doesn't perform the same function. If I follow it properly, it only tests to see if n can be coerced to a number.

On Wednesday, November 27, 2002, at 05:19 PM, Thomas wrote:

Hi all, I have a string like this one "12A4B5" and I want to check for each text item if this is a number and do something or if this not a number and do another thing.

and then On Thursday, November 28, 2002, at 04:49 AM, christian vick wrote:

'as number' is not reliable, since AS doesn't error on some charcters, i.e. space, plus, minus. Not enough, this vary in different AS versions.

And the OP indicated disallowing plus, minus and spaces was also desired.
--
Paul Skinner
_______________________________________________
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.
  • Follow-Ups:
    • Re: Check if it is a number
      • From: John W Baxter <email@hidden>
References: 
 >Re: Check if it is a number (From: "Marc S.A. Glasgow" <email@hidden>)

  • Prev by Date: Coercing a long point
  • Next by Date: My Bad, Idle Handler question fixed & asked again
  • Previous by thread: Re: Check if it is a number
  • Next by thread: Re: Check if it is a number
  • Index(es):
    • Date
    • Thread