• 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: Error-trapping alias properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error-trapping alias properties


  • Subject: Re: Error-trapping alias properties
  • From: Andy Wylie <email@hidden>
  • Date: Thu, 28 Mar 2002 22:55:17 +1200

on 28/3/02 7:13 PM, Paul Berkowitz at email@hidden 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?

I use 'if (get exists alias someFile of application "Finder") = false then'
or try someFile as alias

_____________________________ Andy
_______________________________________________
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.

  • Follow-Ups:
    • Re: Error-trapping alias properties
      • From: Paul Berkowitz <email@hidden>
References: 
 >Error-trapping alias properties (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: AS does not find Filemaker database
  • Next by Date: P/shop five file format
  • Previous by thread: Error-trapping alias properties
  • Next by thread: Re: Error-trapping alias properties
  • Index(es):
    • Date
    • Thread