• 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: Is there a way to speed this up?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to speed this up?


  • Subject: Re: Is there a way to speed this up?
  • From: Brian Christmas <email@hidden>
  • Date: Wed, 05 Oct 2016 11:21:34 +1100

Good grief Shane, it’s no wonder my eyes blur over, and my brain shuts down every time I try and understand AppleScriptObjC!

I never, ever would have come up with that, and even reading it pre-made makes me shudder. I’m presuming it returns just the full matching paragraphs (that each comprise three comma separated items BTW).

I’ll test it, but a big thank you. And no, no πŸ˜€ starts

Regards

Santa


On 5 Oct. 2016, at 11:05 am, Shane Stanley <email@hidden> wrote:

On 5 Oct. 2016, at 10:54 am, Brian Christmas <email@hidden> wrote:

I could post the script, but it might offend.

Confuse, more likely.

Is there any list for Objective C?

There is, but trust me, you really don't want to go there.

As you're already using AppleScriptObjC, why not try that? You could use regular expressions to find the relevant paragraphs, something like this:

-- change encoding to match file
set theString to current application's NSString's stringWithContentsOfFile:(POSIX path of eachFile) encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)
-- make sure match string is regex "safe"
set thePattern to (current application's NSRegularExpression's escapedPatternForString:"abc") as text
-- put a unique character at start of matching lines
set theString to theString's stringByReplacingOccurrencesOfString:(".*" & thePattern & ".*") withString:"πŸ˜€$0" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete all lines that don't start with the unique character
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^[^πŸ˜€].*(\\n|\\r)*" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete the unique character at the beginning of lines
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^πŸ˜€" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- strip trailing returns/linefeeds
set theString to theString's stringByTrimmingCharactersInSet:(current application's NSCharacterSet's whitespaceAndNewlineCharacterSet())
-- convert to paras of AS text
set theParas to paragraphs of (theString as text)

It assumes you don't have any existing paragraphs starting with πŸ˜€.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

And what, you ask, was the beginning of it all?
And it is this......
Existence that multiplied itself
For sheer delight of being
And plunged with numberless trillions of forms
So that it might
find
itself
innumerably

Sri Aurobindo



 _______________________________________________
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: 
 >Re: Is there a way to speed this up? (From: has <email@hidden>)
 >Re: Is there a way to speed this up? (From: Brian Christmas <email@hidden>)
 >Re: Is there a way to speed this up? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Is there a way to speed this up?
  • Next by Date: Re: Placing a new Unix command inside me
  • Previous by thread: Re: Is there a way to speed this up?
  • Next by thread: Re: Is there a way to speed this up?
  • Index(es):
    • Date
    • Thread