• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
TextEdit oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TextEdit oddity


  • Subject: TextEdit oddity
  • From: "koenig.yvan" <email@hidden>
  • Date: Mon, 19 May 2014 16:37:00 +0200

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






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: TextEdit oddity
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Dictionary disapears when renaming app.
  • Next by Date: Re: Using results of dialogs?
  • Previous by thread: Re: Visible messages command in Mail dictionary?
  • Next by thread: Re: TextEdit oddity
  • Index(es):
    • Date
    • Thread