• 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: Network / AS query
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Network / AS query


  • Subject: RE: Network / AS query
  • From: email@hidden
  • Date: Mon, 29 Nov 2004 09:27:43 -0000

Ah! 'exit repeat' - that is the magic command!
 
I am not using handlers (not good enough yet!), and the 'return' was breaking the script, so i took it out.
 
Managed to get on the tecsoft applescript course for this week, so will hopefully learn all about how to rewrite my script using handlers, then it will all come together...
 
Thanks again,
 
James
 

--
Technical Adviser - Global CMS Project
+44 (20) 8652 3917
Reed Business Information

 


From: kai [mailto:email@hidden]
Sent: 27 November 2004 05:03
To: email@hidden
Cc: email@hidden
Subject: Re: Network / AS query



On Friday, November 26, 2004, at 04:29 pm, email@hidden wrote:


Hi Kai / Simon,


sorry for the delay in acknowledging your contributions - just didn't want to flood the list with 'thank-you's' until I had finished it...!


For the reference of the list, I replaced the following code (to find a file in nested folders, which worked fine in OS9, but not well at all in OSX):


[snip: "bad code"]


with the following, which is dramatically quicker:


=== good code (!) ===

set n to jimmyVar & ".jt"

try

        tell application "Finder" to repeat with f in (get folder jtServerPath's folders)

                if exists f's file n then set jobTicketPath to (f as string) & n

        end repeat

end try

======================


As things stand, James, the repeat loop continues to search any remaining nested folders - even after the required file has been found. So you could make the routine even faster (in most cases) by exiting the loop as soon as the file is found.


The return command within the 'getPath' handler of my original suggestion...


----------------------


to getPath of n from p

        set n to n & ".jt"

        tell application "Finder" to repeat with f in (get folder p's folders)

                if exists f's file n then return (f as string) & n

        end repeat

        error "The file \"" & n & "\" could not be found."

end getPath


set jobTicketPath to getPath of jimmyVar from jtServerPath


----------------------


... would exit both the repeat loop and the subroutine as soon as the file was located. However, if you're not using a handler, then you might consider modifying your code to something like this:


======================



set n to jimmyVar & ".jt"

try

        tell application "Finder" to repeat with f in (get folder jtServerPath's folders)

                if exists f's file n then

                        set jobTicketPath to (f as string) & n

                        exit repeat

                end if

        end repeat

end try


======================


HTH


---

kai



r============================ DISCLAIMER =============================
This message is intended only for the use of the person(s)
(\"Intended Recipient\") to whom it is addressed. It may contain
information, which is privileged and confidential. Accordingly
any dissemination, distribution, copying or other use of this
message or any of its content by any person other than the Intended
Recipient may constitute a breach of civil or criminal law and is
strictly prohibited. If you are not the Intended Recipient, please
contact the sender as soon as possible.

Reed Business Information Ltd. and its subsidiary companies
Tel: +44 (0)20 8652 3500

=======================================================================

 _______________________________________________
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

  • Prev by Date: Re: Setting active printer in MS Word 2004?
  • Next by Date: Re: Setting active printer in MS Word 2004?
  • Previous by thread: Re: Network / AS query
  • Next by thread: Address book: how to create a copy of a person?
  • Index(es):
    • Date
    • Thread