• 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: Easier way to check for numbered string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easier way to check for numbered string


  • Subject: Re: Easier way to check for numbered string
  • From: Chris Tangora <email@hidden>
  • Date: Fri, 27 Apr 2007 13:24:59 -0400

Thanks Michelle,

The other two tries come from the different file name structures I am expecting from the rest of the script. I'm including examples of the file name structure I will be expecting to receive as the variable file_nameS. What I have errors out when the first two characters are not numbers. (* Can't make "1N" into type integer. *)



set file_nameS to {"01ABCDEF-Z-1234.pdf", "1NJ0100A1234.pdf", "#PP1NJ0100A1234.pdf"}

repeat with file_name in file_nameS
if (class of (((text 1 through 2 of file_name) as string) as integer) is integer) then
beep
else if (class of (((text 4 through 7 of file_name) as string) as integer) is integer) then
log "booya"
else if (class of (((text 8 through 10 of file_name) as string) as integer) is integer) then
beep
log "Double Booya"
end if
end repeat



What I have right now is so close to what I want. I just want it to ignore the errors while continuing on with the rest of the try. Is that possible?


Thanks.


chris



On Apr 27, 2007, at 11:52 AM, Michelle Steiner wrote:

On Apr 27, 2007, at 8:36 AM, Chris Tangora wrote:

It works fine, but it has to go through three separate "try's" for each file. I was hoping to condense it down to a single if / then, but am having trouble. This is what I have so far, but it doesn't work.

Why does it have to go through three separate tries? If all you're checking for is the first two characters, where do the other two tries come into play?


Anyway, I think this will do it for you:

try
text 1 through 2 of file_name as integer
beep
on error
display alert "Not an integer."
-- handle error as appropriate; the alert is there as a place holder.
end try


-- Michelle

--
"You can fool some of the people all of the time and those are the ones you want to concentrate on."
- George W. Bush at the Gridiron Dinner, Washington, DC March 31, 2001


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Easier way to check for numbered string
      • From: Michelle Steiner <email@hidden>
References: 
 >Easier way to check for numbered string (From: Chris Tangora <email@hidden>)
 >Re: Easier way to check for numbered string (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Easier way to check for numbered string
  • Next by Date: Re: Easier way to check for numbered string
  • Previous by thread: Re: Easier way to check for numbered string
  • Next by thread: Re: Easier way to check for numbered string
  • Index(es):
    • Date
    • Thread