Hello
I'm cleaning 20755 text files. Part of the operation is done by a script and I finish the cleaning by hand.
As the real script make changes to the text, a bare version is :
tell application "TextEdit" to tell document 1 set leTexte to its text
set its text to (leTexte & "=azertyuiop=")
delay 0.1 set properties of its text to {font:"Menlo-Regular", size:11.0}
end tell
For most of the texts, all works well.
I just get a problem with large files. For instance, I have one text containing 141831 characters (including space ones) the script fails and the Events log display :
set properties of every text of document 1 to {font:"Menlo-Regular", size:11.0} --> error number -10000
After that I can't select something in the document's window and I am forced to quit TextEdit and reopen the document which happily is correctly saved.
My first guess was that TextEdit was not ready to apply the changes. So, for see, I splitted the script in two. part 1 :
tell application "TextEdit" to tell document 1 set leTexte to its text
set its text to (leTexte & "=azertyuiop=") end tell
part 2 :
tell application "TextEdit" to tell document 1 set properties of its text to {font:"Menlo-Regular", size:11.0}
end tell
As I waited quite one minute before applying part 2 I thought that all would behave well because applying the changes by hand worked well. Wrong guess, part 2 ended with the same error message. Given that, at this time I'm using a piece of GUIscripting which behave well but I'm not satisfied by that.
tell application "TextEdit" activate tell document 1 set leTexte to its text
set its text to (leTexte & "=azertyuiop=")
end tell end tell tell application "System Events" to tell process "TextEdit" keystroke "t" using {command down, shift down} # switch to RTF tell menu bar 1 to tell menu bar item 5 to tell menu 1 repeat # wait until the format change is really done if enabled of menu item -1 then exit repeat delay 0.1 end repeat end tell keystroke "t" using {command down, shift down} # switch back to Text end tell
Am’I doing something wrong or am’I facing a bug ?
Yvan KOENIG (VALLAURIS, France) lundi 19 mai 2014 16:34:20
|