• 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
Re: TextEdit oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextEdit oddity


  • Subject: Re: TextEdit oddity
  • From: "koenig.yvan" <email@hidden>
  • Date: Wed, 21 May 2014 15:14:12 +0200

Le 21/05/2014 à 12:00, Nigel Garvey <email@hidden> a écrit :

> "koenig.yvan" wrote on Mon, 19 May 2014 16:37:00 +0200:
>
>> 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
>
> Hi Yvan.
>
> I don't know if this helps for your current purpose, but the following
> version of your example script works very well (on my machine) with text
> twice as long as that generated by Deivy's script:
>
>  tell application "TextEdit" to tell document 1's text
>    make new character at end with data "=azertyuiop="
>    set properties to {font:"Menlo-Regular", size:11.0}
>  end tell
>
> 'new character', 'new word', or 'new paragraph' can be used
> interchangeably here. But for some reason, 'new character' works almost
> instantaneously, 'new paragraph' takes a little longer, and 'new word'
> takes quite a while.
>
> If it's not practical for the script to edit the text within TextEdit
> itself, vanilla-edited text can be put back in smaller chunks:
>
>  tell application "TextEdit" to tell document 1
>    set leTexte to its text
>    set leTexteNouveau to (leTexte & "=azertyuiop=") -- or whatever your edit may be.
>    set c to (count leTexteNouveau)
>
>    set its text to ""
>    repeat with i from 1 to (count leTexteNouveau) by 65536
>      set j to i + 65535
>      if (j > c) then set j to c
>      make new character at end of its text with data (text i thru j of leTexteNouveau)
>    end repeat
>    set properties of its text to {font:"Menlo-Regular", size:11.0}
>  end tell
>
>
> NG


I was wrong.

I may use Nigel's scheme after my complete treatment of the documents :

-- my main code builds leTexteNouveau

   set c to (count leTexteNouveau)

   set its text to ""
   repeat with i from 1 to (count leTexteNouveau) by 65536
     set j to i + 65535
     if (j > c) then set j to c
     make new character at end of its text with data (text i thru j of leTexteNouveau)
   end repeat
   set properties of its text to {font:"Menlo-Regular", size:11.0}
end tell

Knowing that, is the behaviour of the original script highligting a bug as Shane and me wrote or is it the real bug by itself ?

Yvan KOENIG (VALLAURIS, France) mercredi 21 mai 2014 15:11:14


 _______________________________________________
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>
References: 
 >Re: TextEdit oddity (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: TextEdit oddity
  • Next by Date: Re: TextEdit oddity
  • Previous by thread: Re: TextEdit oddity
  • Next by thread: Re: TextEdit oddity
  • Index(es):
    • Date
    • Thread