Re: string count in log file
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