• 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: Who owns this bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who owns this bug?


  • Subject: Re: Who owns this bug?
  • From: "S. J. Cunningham via AppleScript-Users" <email@hidden>
  • Date: Thu, 26 Jan 2023 06:24:40 -0500

Jon,

I upgraded to 13.2 and got the same results as you.  Curious that it changed
over the update given Shane’s comments.  It turns out, however, that it is
irrelevant to my problem.  To recap, I have several TextEdit files open in
their own “space” which I use to keep track of various “To Do” lists.  I modify
these over the course of a day without saving after each modification.  At some
point, usually the end of the day, I want each of these edited files to become
the new “original".  I could save each one individually but that is tedious.
So I wrote a script to reinstitute the previous “Save All” menu item.  It does
the trick.  However, I thought I’d modify the script to save only the ones
which had been changed.  Alas, the “modified” property is always false.

What I have discovered is that “modified” property only applies to the current
script.  You can see this by creating two copies of your script:

tell application "TextEdit"
        activate
        set dtf to path to desktop folder as string
        open file (dtf & "sample.txt")
        set text of document 1 to text of document 1 & " NOT"
        set p1 to properties of document 1
        —> p1 = true

end tell

And

tell application "TextEdit"
        activate
        set dtf to path to desktop folder as string
        open file (dtf & "sample.txt")
        -- set text of document 1 to text of document 1 & " NOT"
        set p1 to properties of document 1
        —> p1 = false
end tell

When you run the first copy “modified” is true.  But when you subsequently run
the second copy, “modified” is false even though a look at the sample.txt still
clearly says “edited”.

My conclusion is that the “modified” property is not a property of the document
itself but a flag to keep track of whether the current script has modified the
document.

The bottom line, for me, is that there appears to be no way to tell if an open
TextEdit document has been edited, so I just save everything.

Steve

> On Jan 23, 2023, at 10:42 PM, Jon Pugh <email@hidden> wrote:
>
> I get modified = true for both.
>
> {
>   {class:document, modified:true, path:"/Users/jonpugh/Desktop/sample.txt",
> name:"sample.txt", text:"sample NOT"},
>   {class:document, modified:true, path:missing value, name:"Untitled",
> text:"sample”}
> }
>
> Running 13.2 here.
>
> Jon
>
>
>> On Jan 23, 2023, at 2:39 PM, S. J. Cunningham via AppleScript-Users
>> <email@hidden> wrote:
>>
>> Jon,
>>
>> I’m not sure what you are trying to do here but I get modified=false for
>> both p1 and p2.  Seems to me when you added “NOT”, that’s a modification
>> n'est ce pas?
>>
>>> On Jan 23, 2023, at 5:17 PM, Jon Pugh <email@hidden> wrote:
>>>
>>> tell application "TextEdit"
>>>     activate
>>>     set dtf to path to desktop folder as string
>>>     open file (dtf & "sample.txt")
>>>     set text of document 1 to text of document 1 & " NOT"
>>>     set p1 to properties of document 1
>>>     close document 1
>>>     make new document
>>>     set text of document 1 to "sample"
>>>     set p2 to properties of document 1
>>>     close document 1 without saving
>>>     {p1, p2}
>>> end tell
>>
>> _______________________________________________
>> 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
>

 _______________________________________________
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: Who owns this bug?
      • From: Jon Pugh via AppleScript-Users <email@hidden>
  • Next by Date: Scripting with "spaces'
  • Next by thread: Re: Who owns this bug?
  • Index(es):
    • Date
    • Thread