Hi:
I am a newie with Applescript. I have just finish an example that I have found in the internet but it simple does not work
tell application "TextEdit"
open alias ":Users:ricardomatias
esktop:test.txt"
set word_list to every word of document 1
end tell
tell application "TextEdit"
set word_list to every word of document 1
end tell
set word_frequency_list to {}
repeat with the_word_ref in word_list
set the_current_word to contents of the_word_ref
set word_info to missing value
repeat with record_ref in word_frequency_list
if the_word of record_ref = the_current_word then
set word_info to contents of record_ref
exit repeat
end if
end repeat
if word_info = missing value then
set word_info to {the_word:the_current_word, the_count:1}
set end of word_frequency_list to word_info
else
set the_count of word_info to (the_count of word_info) + 1
end if
end repeat
return word_frequency_list
set the_report_list to {}
repeat with word_info in word_frequency_list
set end of the_report_list to quote & the_word of word_info & ¬
quote & " appears " & the_count of word_info & " times."
end repeat
set AppleScript's text item delimiters to return
set the_report to the_report_list as text
tell application "TextEdit"
make new document with properties {name:"Word Frequencies", text:the_report}
end tell
I am not able to generate the new document with the results.
Can anyone help me?!
All the best
Ricardo
I am a newie with Applescript. I have just finish an example that I have found in the internet but it simple does not work
tell application "TextEdit"
open alias ":Users:ricardomatias
set word_list to every word of document 1
end tell
tell application "TextEdit"
set word_list to every word of document 1
end tell
set word_frequency_list to {}
repeat with the_word_ref in word_list
set the_current_word to contents of the_word_ref
set word_info to missing value
repeat with record_ref in word_frequency_list
if the_word of record_ref = the_current_word then
set word_info to contents of record_ref
exit repeat
end if
end repeat
if word_info = missing value then
set word_info to {the_word:the_current_word, the_count:1}
set end of word_frequency_list to word_info
else
set the_count of word_info to (the_count of word_info) + 1
end if
end repeat
return word_frequency_list
set the_report_list to {}
repeat with word_info in word_frequency_list
set end of the_report_list to quote & the_word of word_info & ¬
quote & " appears " & the_count of word_info & " times."
end repeat
set AppleScript's text item delimiters to return
set the_report to the_report_list as text
tell application "TextEdit"
make new document with properties {name:"Word Frequencies", text:the_report}
end tell
I am not able to generate the new document with the results.
Can anyone help me?!
All the best
Ricardo