• 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
Re: Open Bugs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open Bugs


  • Subject: Re: Open Bugs
  • From: Luther Fuller <email@hidden>
  • Date: Thu, 19 Jan 2012 11:53:22 -0600

On Jan 19, 2012, at 10:42 AM, I wrote:
On Jan 18, 2012, at 2:56 PM, I wrote:

The command ...

tell application "TextEdit" to open fileAlias

if it cannot open the file, perhaps because of permissions, should return an error (number and description) to the script. It does not report an error to the script, but posts a dialog to the manual user.

I've been experimenting with ways to validate the fileAlias before telling an application to open the file.
Here's a script that seems to work ...

try
set filePath to (fileAlias as text)
-- if the next line errors, then filePath is in posix form
-- if the next line does not error, then filePath is in colon form
(fileAlias as text) as alias --> error = -43
on error errText number errNr
set volName to ""
set filePath to (filePath as text)
set AppleScript's text item delimiters to {"/"}
repeat with i from 1 to (count text items of filePath)
if (text item i of filePath) is "Volumes" then
set volName to (text item (i + 1) of filePath)
exit repeat
end if
end repeat
"The disk \"" & volName & "\" may not be mounted."
display dialog the result buttons {"OK"}
return
end try


-- the file alias is valid, continue with script

There are some odd things happening in this script, however.
The line (fileAlias as text) as alias cannot be written as two lines.
If you do that, neither of the lines will error.
And I haven't the slightest idea why the posix/colon path is there. It just is.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Open Bugs
      • From: KOENIG Yvan <email@hidden>
References: 
 >Open Bugs (From: Luther Fuller <email@hidden>)
 >Re: Open Bugs (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Open Bugs
  • Next by Date: Re: Open Bugs
  • Previous by thread: Re: Open Bugs
  • Next by thread: Re: Open Bugs
  • Index(es):
    • Date
    • Thread