Re: Network / AS query
Re: Network / AS query
- Subject: Re: Network / AS query
- From: kai <email@hidden>
- Date: Sat, 27 Nov 2004 05:03:01 +0000
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
_______________________________________________
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