• 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: Line count of a referenced text file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line count of a referenced text file?


  • Subject: Re: Line count of a referenced text file?
  • From: Arthur J Knapp <email@hidden>
  • Date: Tue, 13 Nov 2001 15:05:58 -0500

> Date: Tue, 13 Nov 2001 09:46:36 -0800
> Subject: Re: Line count of a referenced text file?
> From: Christopher Nebel <email@hidden>

> set line_count to 0
> set fp to open for access the_file
> repeat
> try
> read fp until return
> set line_count to line_count + 1
> on error
> -- probably ran out of lines to read.
> exit repeat
> end
> end
> close access fp


> (same as above, but replace the try body with this:)
> read fp for 4096
> set line_count to line_count + count_characters(the result, return)

Whoops, I just posted something that looks almost exactly like this.
Someone is going to think I was plagiarizing. ;-)


> As Paul Berkowitz pointed out, if you know you're counting lines, it's
> faster to just say "count paragraphs of s".

Again, there was a change at some point regarding line-endings in
AppleScript. If *any* line-ending is OK, then "paragraphs" is OK.
Frequently, I have need to separate the count of carrage returns
from newlines.



Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://www.zavatone.com/


  • Prev by Date: Re: Fast Loading & updating of Handler Libraries
  • Next by Date: Re: Line count of a referenced text file?
  • Previous by thread: Re: Line count of a referenced text file?
  • Next by thread: Re: Solved problem -916 errors in remote events
  • Index(es):
    • Date
    • Thread