• 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: Getting count of paragraphs in Scriptable Text Editor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting count of paragraphs in Scriptable Text Editor


  • Subject: Re: Getting count of paragraphs in Scriptable Text Editor
  • From: Michelle Steiner <email@hidden>
  • Date: Thu, 14 Jun 2001 08:44:01 -0700

On 6/13/01 11:33 PM, email@hidden <email@hidden> wrote:

>I'm trying to write a script which involves getting the number of items in a
>list (each followed by a paragraph return) in Scriptable Text Editor.
>I've tried this:
>set theFile to (choose file with prompt "Locate file 'Try List'") as alias
>open for access theFile
>tell application "Scriptable Text Editor"
> set theCount to the count of paragraphs of theFile
>end tell
>display dialog theCount
>
>But I get an error that Applescript expected a reference at " count of
>paragraphs of theFile".
>Can anyone tell me what I'm doing wrong?

"Open for access" opens it for reading by Applescript, not by Scriptable
Text Editor. You never told Scriptable Text Editor to open the file, so
it has no document to count.

Here's a script that will work if you don't have any double carriage
returns in the documenmt; it is application independent, so long as the
document is a text document.

set theFile to (choose file with prompt "Locate file 'Try List'") as alias
set foo to read theFile
set {tid, text item delimiters} to {text item delimiters, return}
set numOfParas to count text items of foo
set text item delimiters to tid
numOfParas

----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------


  • Prev by Date: Opening Hidden Folders in Finder
  • Next by Date: Re: applescript-users digest, Vol 2 #760 - 15 msgs
  • Previous by thread: Re: Getting count of paragraphs in Scriptable Text Editor
  • Next by thread: Re: Getting count of paragraphs in Scriptable Text Editor
  • Index(es):
    • Date
    • Thread