Re: applescript-users digest, Vol 2 #1070 - 16 msgs
Re: applescript-users digest, Vol 2 #1070 - 16 msgs
- Subject: Re: applescript-users digest, Vol 2 #1070 - 16 msgs
- From: Greg Sutherland <email@hidden>
- Date: Tue, 18 Sep 2001 10:31:52 -0400 (EDT)
I got the following script from Marc Myers. It works just fine, but I
want to get the strings from a list rather than prompt for them. I can
create a list and do a repeat with the items, but I don't know how to get
items of the correct type to work in the statement
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, text returned of theRslt}
I know that the problem is that my list is type text, but I can't find any
documentation or examples to help with this.
TIA, greg
set theFile to (choose file with prompt "Pick the file to analyze:" of type {"TEXT"})
set theRslt to (display dialog "Enter the string whose occurrences you want to count:" default answer "")
set fileID to (open for access theFile)
try
set theText to (read fileID)
close access fileID
on error m number n
try
close access fileID
end try
error m number n
end try
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, text returned of theRslt}
set theCount to (count text items of theText) - 1
set AppleScript's text item delimiters to od
display dialog "The string occurred " & (theCount as text) & " time(s)" buttons {"OK"} default button 1