• 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: Thomas <email@hidden>
  • Date: Sat, 30 Nov 2002 20:30:25 +0100

Yea, sorry I'm not clear because I have two differents scripts in mind where I encounter this problem.
The first one is just to check if the string is only composed of numbers, I was wondering what was the best method :
- repeat on each text item to check if it's in {1,2,...,9}, it seems slower than the other method
- try block like you did
- "AB45DJI" is a number --> false; would be cool but that doesn't work

The second script, take each text item of a string in a repeat loop, check if it's a number or not, and process the text item depending if it's a number or not. Same problem.

I guess the try block is the best method (because it's faster).

Thanks Thomas

Paul Skinner wrote :

It isn't clear what you want to do. If you want to do something to the characters that fail, or remove them, then you need to loop through them. If you just want to check that your input is composed of digits and doesn't contain -,+, or spaces you could...

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
end NumeralsOnly

--
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.

References: 
 >Re: Check if it is a number (From: Paul Skinner <email@hidden>)

  • Prev by Date: Re: Check if it is a number
  • Next by Date: Re: checking form of input
  • Previous by thread: Re: Check if it is a number
  • Next by thread: "tell application" without starting application?
  • Index(es):
    • Date
    • Thread