Debug help? Subroutine and Global Variable?
Debug help? Subroutine and Global Variable?
- Subject: Debug help? Subroutine and Global Variable?
- From: "T.J. Mahaffey" <email@hidden>
- Date: Tue, 16 Oct 2001 10:48:22 -0500
Hi, folks!
I've run into a very frustrating series of problems. Here's what I have. It
worked great before I tried to make it recursive and do subfolders.
There may actually be more than one thing wrong with this after I've made
some various changes in the heat of my frustration. Currently, I get the
completion alert, but it never actually does the setting of the comments on
the items as it's supposed to. Secondly, anytime I compile it, it actually
runs and prompts the first dialog for the comments info to be set, but I'm
just compiling, dang'it! Have I set up this global variable wrong?
Finally, I always like my scripts to handle both as a droplet as well as
being able to run them from the apple menu on a selection.
Could someone go through this thing and point out where I'm doing things
wrong? As always, your help has been invaluable in my learning process.
--- start script
property addedComments : {text returned of (display dialog "Enter new
comments information:" buttons {"Cancel", "OK"} default button "OK" default
answer "" with icon 1)}
on open fileList
setName(fileList) of me
display dialog "Your entered information has now been inserted into the
comments of the selected files." with icon 1
end open
on run
tell application "Finder"
tell me to setName(fileList)
end tell
end run
on setName(fileList)
tell application "Finder"
activate
set theseFolderItems to every item in fileList
repeat with thisItem in theseFolderItems
if kind of thisItem is not "Folder" then
set the fileList to every item of the selection
repeat with thisItem in fileList
set currentComments to comment of thisItem
if currentComments = "" then
set comment of thisItem to addedComments & ", "
else
set comment of thisItem to currentComments & ", " &
addedComments & ", "
end if
end repeat
display dialog "Your entered information has now been
inserted into the comments of the selected files." with icon 1
else
my setName(thisItem) -- Recursive! This is the part that
makes it work on subfolders. Notice the subroutine is calling itself.
end if
end repeat
end tell
end setName
-- end script
Many thanks in advance.
T.J. Mahaffey
email@hidden