• 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: Basic script blues ;-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic script blues ;-)


  • Subject: Re: Basic script blues ;-)
  • From: Andrew Oliver <email@hidden>
  • Date: Sun, 27 Mar 2005 10:15:37 -0800

On 3/27/05 9:45 AM, "Bernard Azancot" <email@hidden> wrote:

> Just a little question.
>
> Two versions of the same basic script.
> Both compile.
> The first one is OK (a folder is created, when not existing).
> The second not.
> I cannot find what is the problem with the 2nd one...
[snip]

> -- 2nd script: wrong --
>
> try
> tell application "Finder"
> set Folder1 to folder ("IBM 01:Users:parents:Desktop:Foo")
> if not (exists folder (Folder1 & ":Folder2")) then
> make new folder at folder Folder1 with properties {name:"Folder2"}
> end if
> end tell
> end try
>
> -- end of 2nd script--

The second script fails because of the line:

> set Folder1 to folder ("IBM 01:Users:parents:Desktop:Foo")

If this folder doesn't exist it generates an error. This error is caught by
the 'try' handler and your script drops to the (non-existent) error handler.

In other words the script doesn't get to the 'if not (exists...' line
because it was unable to get the folder in the previous script.

One way of rewriting this would be to:

> try
>   tell application "Finder"
>     set Folder1 to folder ("IBM 01:Users:parents:Desktop:Foo:")
>   end tell
> on error
>   -- we get here if the above line fails
>   make new folder at folder "IBM 01:Users:parents:Desktop:Foo:" with
properties {name:"Folder2"}
> end try


Andrew
:)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Basic script blues ;-)
      • From: Bernard Azancot <email@hidden>
References: 
 >Basic script blues ;-) (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Re: Basic script blues ;-)
  • Next by Date: Re: Basic script blues ;-)
  • Previous by thread: Re: Basic script blues ;-)
  • Next by thread: Re: Basic script blues ;-)
  • Index(es):
    • Date
    • Thread