Re: applescript-users digest, Vol 2 #113 - 11 msgs
Re: applescript-users digest, Vol 2 #113 - 11 msgs
- Subject: Re: applescript-users digest, Vol 2 #113 - 11 msgs
- From: SemiColon <email@hidden>
- Date: Fri, 8 Dec 2000 22:06:46 -0800
At 9:00 PM -0500 12/8/00, email@hidden wrote:
>
In a message dated 12/8/00 8:29:28 PM,
>
email@hidden writes:
>
>
>on open {theItem}
>
> display dialog FilenameFromPath(theItem)
>
>end open
>
>
>
>on FilenameFromPath(thePath)
>
> set saveDelim to AppleScript's text item delimiters
>
> set AppleScript's text item delimiters to ":"
>
> set pathAsList to text items of thePath
>
> if the last character of thePath is ":" then
>
> set idx to (the number of text items in thePath) - 1
>
> else
>
> set idx to -1
>
> end if
>
> set folderName to item idx of pathAsList
>
> set AppleScript's text item delimiters to saveDelim
>
> return folderName
>
>end FilenameFromPath
>
>
>
I tried to run this script and I get an error "Can't get every text item of
>
alias (somefolder)" which errors on the line:
>
>
set pathAsList to text items of thePath
>
>
I'm on OS 8.6. Is this new language for OS 9?
It errors on OS 9 also. If I change the script slightly for Script
Editor to run it (replace the "on open" block with -->
set theItem to choose file --(or folder)), and run it with the
event log open, the event log tells me "thePath" is an alias.
"thePath" needs to be coerced to string for the rest of the script to
work. Add "set thePath to thePath as string" as a line following
"on FilenameFromPath(thePath)" and it should work OK.
;