• 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: string count in log file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string count in log file


  • Subject: Re: string count in log file
  • From: Greg Sutherland <email@hidden>
  • Date: Mon, 17 Sep 2001 14:41:21 -0400 (EDT)

Thanks to Marc I have a good start, but I still have questions.

I would like to get the strings that I'm counting from a list in the
script or a separate input file. I get an error when the string comes
from a list. "Can't get text returned of "the string" is the error
message. Also, I want the counts written to a file. I figured out how to
write to a file, but I can't get the value of theStrng into the output.

All comments and suggestions would be appreciated very much.

Here is what I have so far:

set theFile to (choose file with prompt "Pick the file to analyze:" of
type {"TEXT"})
set fileID to (open for access theFile)
(*
set theStrng to (display dialog "Enter the string whose occurrences you
want to count:" default answer "")
*)
set theStrng to "database"
try
set theText to (read fileID)
close access fileID
on error m number n
try
close access fileID
on error o number p
display dialog "error " & o & " " & p
end try
error m number n
end try
set {od, AppleScript's text item delimiters} to {AppleScript's text item
delimiters, text returned of theStrng}
set theCount to (count text items of theText) - 1
set AppleScript's text item delimiters to od

tell application "Finder"
activate
select file "logfile counts"
open selection
end tell
tell application "Microsoft Word"
activate
set contents of selection to theStrng & " occurred " & (theCount
as text) & " times in " & theFile
set contents of selection to "
"
save window "logfile counts"
quit
end tell


  • Prev by Date: empty trash with locked files
  • Next by Date: Re: can't get the folder of info for x
  • Previous by thread: Re: string count in log file
  • Next by thread: Re: string count in log file
  • Index(es):
    • Date
    • Thread