• 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 15:34:21 -0400

I just converted it back to a modified original as I need the entire script done in the next 1/2 hour. This is how the script runs now. While it still has a few more try's than I'd like, it is smaller than the original. With more time I think I would have looked at has' TextCommands, as it does what I am looking for.

Thanks Michelle & has.


Chris


property test1 : "" property test2 : "" property test3 : ""



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

repeat with file_name in file_names

try
set test1 to (((text 1 through 2 of file_name) as string) as integer)
on error
try
set test2 to (((text 4 through 7 of file_name) as string) as integer)
on error
set test3 to (((text 8 through 10 of file_name) as string) as integer)
end try
end try

log file_name
log test1
log test2
log test3


if (class of test1 is integer) then
say "Boy I tell you what."
else if (class of test2 is integer) then
say "Oh yeah DUDE!"
else if (class of test3 is integer) then
say "Double Booya"
end if

set test1 to ""
set test2 to ""
set test3 to ""

end repeat






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
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: perl regex works differently within a "do shell script" than from within perl
  • 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