• 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: How to create a document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a document?


  • Subject: Re: How to create a document?
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 06 Jun 2016 10:58:11 +0200


Le 5 juin 2016 à 20:43, Yvan KOENIG <email@hidden> a écrit :

…

I just repeated the described scheme with the same result.
It's just when I ran the second script one more time that I got the described error.
So, at last, it seems that the correct scheme is the script which saves during the closing process and reopen the file immediately.
We may strip it a bit:

set testFile to "This is a test.txt"
set thePath to ((path to desktop as text) & testFile) as «class furl»
tell application "TextEdit"
activate
make new document
tell document 1
close it saving yes saving in thePath
end tell
open thePath
# Now we may work as we want upon the document
end tell


Funny feature.

Compare what we get with the script above and this edited version in which we don't explicitly ask the script to save :

set testFile to "This is a test.txt"
set thePath to ((path to desktop as text) & testFile) as «class furl»
tell application "TextEdit"
activate
make new document
tell document 1
close it saving in thePath --saving yes
end tell
open thePath
# Now we may work as we want upon the document
end tell


In both case we have a document correctly saved but in the first one we have the tool bar and the rule as in rtf files and in fact it's really an RTF file whose name ends with .txt.
In the second we haven't them exactly as when the file is defined as a text one and it's really such one.

I made some complementary tests. When we don't explicitly ask to save with "saving yes", the format of the file is defined by the extension used in the name.
set testFile to "This is a test.txt" and we will get a text file.
set testFile to "This is a test.rtf" and we will get an RTF one.

I got this behavior with an application which is set to create new documents as RTF ones which is the factory setting .


Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) lundi 6 juin 2016 10:58:01


 _______________________________________________
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: How to create a document?
      • From: Jim Underwood <email@hidden>
References: 
 >Re: How to create a document? (From: Mitchell L Model <email@hidden>)
 >Re: How to create a document? (From: Yvan KOENIG <email@hidden>)
 >Re: How to create a document? (From: Bruce Robertson <email@hidden>)
 >Re: How to create a document? (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: How to create a document?
  • Next by Date: Re: Mark Alldritt's Journal » Script Debugger 6 Release Notes (6A162)
  • Previous by thread: Re: How to create a document?
  • Next by thread: Re: How to create a document?
  • Index(es):
    • Date
    • Thread