• 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 'alias' error when the file no longer exists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why doesn't 'alias' error when the file no longer exists?


  • Subject: Why doesn't 'alias' error when the file no longer exists?
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 18 Dec 2000 07:46:15 -0800

For some time, I have saved the results of 'choose file' into script
properties as alias, so that the user is free to move or rename the chosen
file afterwards and still have the script go on working.

I always believed that the 'alias' form would error if the file no longer
existed on the computer, so I would frequently error trap for it near the
beginning of a script, something like

property theFile : "" --since saved as alias "Hard Disk:Some Folder:Some
File"

-- set-up section including
if theFile = "" then set theFile to choose file with prompt "blah blah"
--i.e.as alias

try
get theFile
on error
display dialog "Squawk! You've deleted your file - make a new one."
return
end try

--on goes the script

I have now discovered that this doesn't error, even when the file no longer
exists. It still produces:

get theFile
-- alias "Hard Disk:Some Folder:Some File"

even when there is no such file, and errors in a less controlled way further
down the script. You can also do

theFile as string
-- "Hard Disk:Some Folder:Some File"

and use tids to get the file's name (which is useful). The test that works
is:

try
get alias (theFile as string)
on error
display dialog "Squawk!"
end try

That must force the script to try to resolve (is that the word?) the alias
afresh. If it exists, all is well, if it doesn't, the error trap works.

If the file has been moved and/or renamed, not deleted, it always resolves
correctly to its new path name:

get theFile
--Hard Disk:Another Folder:Another FileName

or
--Hard Disk:trash:Some File

if that's where it is.

Why does it give the result

get theFile
-- alias "Hard Disk:Some Folder:Some File"

when there is no such thing?

--
Paul Berkowitz


  • Follow-Ups:
    • Re: Why doesn't 'alias' error when the file no longer exists?
      • From: Emmanuel <email@hidden>
  • Prev by Date: OT: VPN clients/protocols
  • Next by Date: speak a message through the phone connection help
  • Previous by thread: Re: Executing AScripts automatically?
  • Next by thread: Re: Why doesn't 'alias' error when the file no longer exists?
  • Index(es):
    • Date
    • Thread