Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a handler runs after compile, but never again



Whoops, I just saw your comment about the file path not existing. My solution would not work in that case I believe. In your case the best bet would be to do it the way you are. Michelle's earlier solution is spot-on, but I would save the old text item delimiters and restore them rather than setting them to null. This is friendlier and will break less things if you happen to use delimiters at some other point in your script:

--tell application "Finder"
set filepathstring to "Macintosh HD:Users:spoun:Desktop:demofolder:mappa Ordner:mappa2:mappa3:"
display dialog theContainer(filepathstring) of me
--end tell

on theContainer(filepath)
--tell application "Finder"
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set aContainer to (filepath's text items 1 thru -3) as string
set AppleScript's text item delimiters to oldDelims
set aContainer to aContainer & ":" as string
--end tell
return aContainer
end theContainer

On Nov 30, 2003, at 11:26 AM, Graff wrote:

If you are just looking for the folder that encloses a certain file this statement works fine:
set theContainer to (the container of the file filepathstring) as text

It looks like you want the grandparent folder (2 folders up from the file) so you would do this:
set theContainer to (the container of the container of the file filepathstring) as text

This would would eliminate the need for a separate function to do this, since the entire contents of the function are replaced by 1 line of code. It's a cleaner solution than fooling around with text item delimiters and all.

On Nov 30, 2003, at 10:40 AM, Matyas Ferenc Farkas wrote:

hi,

there is the troublemaker:

tell application "Finder"
set filepathstring to "Macintosh HD:Users:spoun:Desktop:demofolder:mappa Ordner:mappa2:mappa3:"
log theContainer(filepathstring) of me
end tell

on theContainer(filepath)
tell application "Finder"
set AppleScript's text item delimiters to ":"
set theContainer to (filepath's text items 1 thru ((count (every text item in (filepath as string))) - 2)) as string
set AppleScript's text item delimiters to ""
set theContainer to theContainer & ":" as string
end tell
return theContainer
end theContainer

if i modify something, and run once it runs, but if i run it one more time, the error message:

Script untitled 6 started
tell current application
theContainer("Macintosh HD:Users:spoun:Desktop:demofolder:mappa Ordner:mappa2:mappa3:")
theContainer("Macintosh HD:Users:spoun:Desktop:demofolder:mappa Ordner:mappa2:mappa3:")
end tell
Script untitled 6 finished
--> +script; doesn't understand the theContainer message.

i need this workaround, becouse the filepath does not exists at run time as an alias. thanks for any comments.

--
Ferenc Farkas Matyas
-=-=-=-=-=-=-=-=-=-=-=-=-=-
email/iChat : spoun @ mac.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.

References: 
 >a handler runs after compile, but never again (From: Mátyás Ferenc Farkas <email@hidden>)
 >Re: a handler runs after compile, but never again (From: Graff <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.