• 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: Read for 1000 until nearest space?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read for 1000 until nearest space?


  • Subject: Re: Read for 1000 until nearest space?
  • From: Philip Aker <email@hidden>
  • Date: Mon, 13 Oct 2008 20:41:52 -0700

On Oct 13, 2008, at 7:59 PM, Joe wrote:

The read command can step through a larger text file piece by piece, say i000 bytes at a time.

--for example
set fr to open for access file "S:Users:j:Desktop:aaa.txt"
try
 repeat
   set x to read fr for 1000
   display dialog x
 end repeat
end try
close access fr

Is there any way to get it to break at the space character nearest to 1000 bytes rather than the middle of a word?

Seems like it has to be a composite operation:

set p2d to (path to desktop folder as text)
set fpath to p2d & "aaa.txt"
try
set fd to open for access fpath
set d1 to read fd for 50
set d2 to read fd until space
close access fd
set res to d1 & d2
{res, length of res}
on error
try
close access fd
end try
end try


Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

 _______________________________________________
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: Read for 1000 until nearest space?
      • From: Joe <email@hidden>
References: 
 >Read for 1000 until nearest space? (From: Joe <email@hidden>)

  • Prev by Date: Need Script To Copy User Folder to External Drive
  • Next by Date: Re: Read for 1000 until nearest space?
  • Previous by thread: Read for 1000 until nearest space?
  • Next by thread: Re: Read for 1000 until nearest space?
  • Index(es):
    • Date
    • Thread