Why doesn't this cause an error?
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.