Well, I kept reading the threads in the forums, learning, and I figured it out at last:
tell application "TextWrangler"
set textBlock to the text of document 1
set nrWords to (count words of textBlock) --gets the number of words in the text
set myTID to ""
set wordList to words of textBlock -- gives a list of all the words
set AppleScript's text item delimiters to myTID
repeat with myItem in wordList
set nrRepeats to 1
set searchNr to "([0-9]+)"
set s_options to {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
if found of (find searchNr searching in text window 1 options s_options with selecting match) then
set foundNr to contents of selection
set numerale to load script alias ((path to desktop as string) & "script-uri de lucru:primele3:03. numere.scpt")
tell numerale to run
end if
if myItem is not in {"a", "à ", "á", "â", "ã", "ä", "Ã¥", "Ä", "Ä…", "ă", "æ", "â", "b", "c", "d", "e", "é", "f", "g", "h", "i", "î", "j", "k", "l", "m", "n", "o", "ö", "p", "q", "r", "s", "ÅŸ", "È™", "t", "Å£", "È›", "u", "û", "ü", "Å«", "v", "w", "x", "y", "z", "$", "¢", "£", "¥", "฿", "€", "%", "?", "!", "&", "AM", "an", "as", "at", "do", "in", "is", "no", "of", "on", "PM", "so", "to", foundNr} then
set first3 to (characters 1 thru 3 of myItem)
set first3ch to load script alias (((path to desktop as string) & "script-uri de lucru:primele3:" & first3 as string) & ".scpt")
tell first3ch to run
end if
end repeat
set adjsubst to load script alias ((path to desktop as string) & "script-uri de lucru:primele3:02. adjective & substantive.scpt")
tell adjsubst to run
set ff to load script alias ((path to desktop as string) & "script-uri de lucru:primele3:04. finisare finala.scpt")
tell ff to run
display dialog ("Initial text had " & nrWords & " words" as string) with icon 1 giving up after 120
end tell
Woo-hoo! Macscripter is really helpful. Thank you all! The only remaining problem is that it searches for a “bri.scpt” (from “Marea>Britanie”), and I didn’t yet figured out how to skip that.
I have yet another question: Perl comes standard on all Macs. Is it possible to use perl commands for grepping the text with TextEdit, even though it doesn’t support grep by itself? The only shortcoming with Textwrangler is that it misses the formatting of the text (all the bold, italics and size differences are gone). I’m already pretty good with regular expressions, so what do you think? Which is the best route?
p.s. I found out why some of the scripts suggested at the beginning of this thread didn’t work on my Mac. I was still on Panther, that’s why. Sorry