Re: Error-trapping alias properties
Re: Error-trapping alias properties
- Subject: Re: Error-trapping alias properties
- From: Paul Skinner <email@hidden>
- Date: Thu, 28 Mar 2002 23:43:21 -0500
On Thursday, March 28, 2002, at 05:48 PM, Paul Berkowitz wrote:
In the meantime, does the same thing occur if you:
1) Empty the trash
2) Also restart the computer
I modified the script slightly for additional clarification.
--script saved as an application
property someFile : ""
try
someFile as alias
on error
set someFile to choose file
end try
display dialog (((class of someFile) as text) & " \"" & someFile as
text) & "\""
--end script
Summary:
If I run the script and choose the file 'testFile' on the desktop I
get...
alias "OSX:Users:paulskin:Desktop:testFile"
If I move the aliased file to the trash I get...
alias "OSX:Users:paulskin:.Trash:testFile"
If I empty the trash then I get...
alias "OSXUsers:paulskin:Desktop:testFile"
Note that the missing colon is NOT a typo.
If I logout and log back in I get...
alias "OSXUsers:paulskin:Desktop:testFile"
If I restart I get...
alias "OSXUsers:paulskin:Desktop:testFile"
The results are the same if the file is chosen from other than the
desktop.
--
On Thursday, March 28, 2002, at 06:49 PM, Andy Wylie wrote:
I wasn't clear and the examples were wrong sorry. The key seems to be
'as
string'
Anything that tries to use the alias fails to resolve it and errors out.
The odd thing is that the finder doesn't properly 'break' the alias when
the original item is deleted.
On Thursday, March 28, 2002, at 08:39 PM, Paul Berkowitz wrote:
Right. The point is that I want to store the result as alias to allow
the
user to move the file around without having to find it again. But
storing an
On Thursday, March 28, 2002, at 09:34 PM, Andy Wylie wrote:
[1]the examples I gave all use 'choose file' to set the property, does
that
not return an alias under os x?
Under all AS and OS versions 'choose file' returns an alias.
On Thursday, March 28, 2002, at 05:48 PM, Paul Berkowitz wrote:
I have to admit I was extrapolating (logically, I thought!) for the
"trashed
file" scenario. I hadn't tested that specifically. I have had first-hand
experience of what happens when you export the _script_ from one
computer to
another when it already has an alias to a file on a different computer,
in
both OS 10.1.3 (A In fact, I believe - if I recall correctly - the error
refers to the named disk not being present, which could be significant
in
the light of what you found running the script on the same computer,
just
the file itself trashed.
It's possible that the situation you tested, where the disk and all
directories (folders) along the path, up to but not including the file
name
itself, may work differently, at least in OS X. I'll test as soon as I
have
time.
In the meantime, does the same thing occur if you:
1) Empty the trash
2) Also restart the computer
It could be that the file maintains some sort of ghostly existence in
memory
until logout or reboot. ?
--
Paul Berkowitz
From: Paul Skinner <email@hidden>
Date: Thu, 28 Mar 2002 16:17:45 -0500
To: AppleScript Users <email@hidden>
Cc: Paul Berkowitz <email@hidden>
Subject: Re: Error-trapping alias properties
Funny thing, I tried to test this and found a...bug?
OS X 10.1.3 / AS 1.8.1. What OS / ASv are you using?
--Script saved as an application
property someFile : ""
try
someFile as alias
on error
set someFile to choose file
end try
display dialog someFile as text
--end script
This asks you to choose a file then stores an alias to the file in the
property.
It then displays the current path to the file in a dialog.
If you move the file then run the script again it shows you the new
path.
cool so far.
Now I trashed the file and ran the script again and...
No error!
And it displays the original path from the Choose File assignment!
WTF?
On Thursday, March 28, 2002, at 02:13 AM, Paul Berkowitz wrote:
Is there a way to error-trap alias objects saved as script properties,
in
case the file has been trashed and emptied or the script moved to
another
computer?
I have lots of scripts that begin:
property someFile : ""
if someFile = "" then
set someFile to choose file with prompt "Find whatever"
-- result is 'alias "Some File Path"'
end if
Saving the property in alias form, rather than 'as string', is great
in
case
the user moves or renames the file. Anticipating the case where s/he
might
move the script to another computer, I've usually added:
property someFile : ""
if someFile /= "" then
try
get someFile
on error
set someFile to ""
end try
end if
if someFile = ""
-- etc
to go through the initializing setup again. But it doesn't work as I
intended, because the very first line:
property someFile : [actually the saved alias]
itself errors before I can ever get to that trap. It's certainly not
possible to put the property declaration in a try/error block. So I
was
wondering if anyone knows any way around this conundrum:
Can you store an alias as a script property, and still find a graceful
way
to set a new value (via choose file again, e.g.) if the file no longer
exists?
I know that storing the string file path to the file wouldn't hit this
problem, but then it would throw up an error , or dialog if trapped,
every
time the file is moved or renamed. Is there some way around this?
--
Paul Berkowitz
_______________________________________________
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.
--
Paul Skinner
Digital Assets Manager
Thinkstock
Uncommon Imagery for Intelligent Design
http://www.thinkstock.com
704-716-9371 N.C.
1-888-646-1606 USA
001-704-716-9367 INTL
_______________________________________________
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.
--
Paul Skinner
Digital Assets Manager
Thinkstock
Uncommon Imagery for Intelligent Design
http://www.thinkstock.com
704-716-9371 N.C.
1-888-646-1606 USA
001-704-716-9367 INTL
_______________________________________________
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.