• 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
Why doesn't this cause an error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why doesn't this cause an error?


  • Subject: Why doesn't this cause an error?
  • From: Mr Tea <email@hidden>
  • Date: Tue, 24 Sep 2002 01:33:49 +0100

set theName to "01 Picture"
set startHere to ((offset of " " in theName) + 1)
set endHere to ((offset of "." in theName) - 1)

set theDisplayName to text startHere thru endHere of theName

--> "Picture"

I originally tested this with 'theName' set to "01 Picture.jpg", but wanted
to see what would happen if the script encountered a file without a name
extension. I expected an error, but got none. The same result occurs if any
glyph that is not in the original string is used in place of "."

So, when the offset of a character that is not in a string is asked for, the
result returned is zero (the insertion point before the first letter). Is
this the intended behaviour, or a bug? The way things are, it means that I
don't need fancy checking routines to see if file names have extensions, but
a dialog telling me that the script can't get the offset of "." would have
seemed more likely.


Nick
pp Mr Tea
_______________________________________________
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: Why doesn't this cause an error?
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Patch for Smile 2.4.6.
  • Next by Date: Extra data in resource or attached file?
  • Previous by thread: Patch for Smile 2.4.6.
  • Next by thread: Re: Why doesn't this cause an error?
  • Index(es):
    • Date
    • Thread