• 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: Any way to get "file pointer"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any way to get "file pointer"?


  • Subject: Re: Any way to get "file pointer"?
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 01 Jun 2018 20:31:07 -0500

On 06/01/2018, at 19:18, Gil Dawson <email@hidden
<mailto:email@hidden>> wrote:
> I'm looking for the number of bytes I've read so far.


Hey Gil,

As far as I know you're out-of-luck when it comes to the using the
StandardAdditions `read` command for this.

I expect it's “easily” possible with AppleScriptObjC, but I don't have time to
go fishing at the moment.

Perhaps Shane will pop in and show us the way.  :)

The easiest way I know of is to use the Satimage.osax
<http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html>.

--
Take Care,
Chris


tell application "System Events" to ¬
    set theFile to path of disk item "~/test_directory/list.txt"

set startPos to 0

repeat

    set findRec to find text ".+(?=\\n)" in (alias theFile) starting at
startPos with regexp
    set startPos to (matchPos of findRec) + (matchLen of findRec)
    findRec
    "" --> break point in Script Debugger

end repeat

--> {matchPos:0, matchLen:3, matchResult:"one"}
--> {matchPos:4, matchLen:3, matchResult:"two"}
--> {matchPos:8, matchLen:5, matchResult:"three"}


(*

Satimage.osax -- Find Text Syntax

set theResult to find text searchString ¬
    in textToSearch ¬
    starting at integer ¬
    for integer ¬
    case sensitive false ¬
    regexp true ¬
    whole word false ¬
    regexpflag {"IGNORECASE", "EXTEND", "MULTILINE", "SINGLELINE", "FIND
LONGEST", ¬
    "FIND NOT EMPTY", "DONT CAPTURE GROUP", "NOTBOL", "NOTEOL"} ¬
    using returnString ¬
    all occurrences true ¬
    string result true ¬
    syntax {"POSIX", "POSIX_EXTENDED", "EMACS", "GREP", "GNU_REGEX", "JAVA",
"PERL", ¬
    "RUBY"} --» Default: "RUBY --» Comma means logical OR."

*)




 _______________________________________________
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

References: 
 >Any way to get "file pointer"? (From: Gil Dawson <email@hidden>)
 >Re: Any way to get "file pointer"? (From: Steve Mills <email@hidden>)
 >Re: Any way to get "file pointer"? (From: Gil Dawson <email@hidden>)

  • Prev by Date: Re: Any way to get "file pointer"?
  • Next by Date: Re: Any way to get "file pointer"?
  • Previous by thread: Re: Any way to get "file pointer"?
  • Next by thread: Re: Any way to get "file pointer"?
  • Index(es):
    • Date
    • Thread