• 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: How can I pass a counter result out of a script object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: kai <email@hidden>
  • Date: Sat, 15 Nov 2003 05:01:11 +0000

on Sat, 15 Nov 2003 02:11:58 +0000, I wrote:

> on Fri, 14 Nov 2003 13:06:15 -0600, Mark Clyma wrote:
>
>> I have an applescript droplet that uses Jon's Commands X 3.0 to walk a
>> given folder and its associated sub-folders and files. I want the
>> script to process only the text files that end in ".php". I then want
>> the script to use BBEdit to take the collected ".php" text files and
>> open each one and search for a "xml" tag and then delete the tag line
>> and save, close the file. Then process the rest of the collected ".php"
>> files the same way. I can get the script to work very well but I can
>> not figure how to "display dialog", at the very end of the script when
>> the processing is done, the variable "gfileUpdated" (this line in the
>> script: "set gfileUpdated to gfileUpdated + 1", found in the middle of
>> the script in a "if" statement). The "gfileUpdated" variable holds the
>> number of files updated (the number of ".php" files whose "xml" tag line
>> was deleted). When I try to display the variable at the end of the
>> script I always end up with zero (0). I have tried several things to
>> get the script to display the correct number of files updated but
>> nothing seems to work. Does anyone have a solution?
>
> Possibly, Mark (see below)...

Of course, a much 'quieter' method might be to avoid using BBEdit for the
purpose altogether - something like this:

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

property e : ".php"
property x : "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"

on open (f)
script s
property l : {}
property c : 0
on open f
set n to f as string
if n ends with e then
set l's end to n
set t to read f
set text item delimiters to x
set t to t's text items
if (count t) > 1 then set c to c + 1
set text item delimiters to ""
set eof f to 0
write (t as string) to f
end if
{l, c}
end open
end script
set {l, c} to walk folders f with script s without invisibles
display dialog "Files ending in \".php\": " & (count l) & "
Files with tags stripped: " & c
end open

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

(Then you would presumably do something with the list 'l'...)

---
kai
_______________________________________________
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.

  • Prev by Date: Re: Font Panel
  • Next by Date: Re: How can I pass a counter result out of a script object
  • Previous by thread: Re: How can I pass a counter result out of a script object
  • Next by thread: Re: How can I pass a counter result out of a script object
  • Index(es):
    • Date
    • Thread