Re: How can I pass a counter result out of a script object
Re: How can I pass a counter result out of a script object
- Subject: Re: How can I pass a counter result out of a script object
- From: Bill Metzinger <email@hidden>
- Date: Sat, 15 Nov 2003 20:09:53 -0500
Your script changes the files but loses the variable gfileUpdated on
the way out of script foo.
Kai's second example works good.
If you want to try a third way, this example walks nested folders
without jons commands, uses BBEdit, but doesn't bother opening the
files.
*******
property gFileExtToSave : {".php"}
property gTagToDelete : "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"
global FileList, gfileUpdated
on open (filfol)
set FileList to {}
set gfileUpdated to 0
repeat with objectRef in filfol
set itsInfo to (info for objectRef)
if folder of itsInfo then
searchFolder(objectRef as string)
else
doFileStuff(objectRef as string)
end if
end repeat
activate
display dialog ,
"The number of files that had the xml line deleted was: " &
gfileUpdated
end open
on doFileStuff(what)
set tSourceFileName to a reference to what as string
if tSourceFileName ends with gFileExtToSave then
copy what as string to end of FileList
tell application "BBEdit"
set findText to replace gTagToDelete using "" searching in what as
alias ,
saving yes options {showing results:false}
if found of findText then
set gfileUpdated to gfileUpdated + 1
end if
end tell
end if
return {FileList, gfileUpdated}
end doFileStuff
on run
display dialog "To use this script, " & return & ,
"drop files or folders onto it." buttons {"Right right..."} default
button 1
end run
on searchFolder(whatFolder)
if last character of whatFolder is not ":" then
set whatFolder to whatFolder & ":"
end if
set folderList to (list folder of file whatFolder)
repeat with thisFolder in folderList
set itsName to whatFolder & contents of thisFolder
set itsInfo to (info for file itsName)
if folder of itsInfo then
searchFolder(itsName)
else
doFileStuff(itsName)
end if
end repeat
end searchFolder
*******
} Where'd you get the coconuts?
} We found them.
} Found them? In Mercea? The coconut's tropical!
} What do you mean?
} Well, this is a temperate zone.
_______________________________________________
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.