• 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: Email to Script Debugger or Script Editor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Email to Script Debugger or Script Editor


  • Subject: Re: Email to Script Debugger or Script Editor
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 20 Nov 2015 10:09:55 +1100

On 20 Nov 2015, at 1:49 AM, Christopher Stone <email@hidden> wrote:

but writing handlers in ASObjC to fully replace the SIO's find text and change commands has proven rather difficult

I suspect you'd do better to rewrite the handlers that use it, rather than the command itself -- commands with lots of optional parameters are always complicated to replace. You may end up with more handlers, but have to supply fewer parameters to use them.

So your three could become:

on replaceThis:theFind inThis:theString withThis:theReplace
set anNSString to current application's NSString's stringWithString:theString
set theResult to anNSString's stringByReplacingOccurrencesOfString:theFind withString:theReplace options:((current application's NSRegularExpressionSearch) + (current application's NSCaseInsensitiveSearch as integer)) range:{0, anNSString's |length|()}
return theResult as text
end replaceThis:inThis:withThis:

on returnFirstMatchOf:theFind inThis:theString
set anNSString to current application's NSString's stringWithString:theString
set theRange to anNSString's rangeOfString:theString options:((current application's NSRegularExpressionSearch) + (current application's NSCaseInsensitiveSearch as integer))
if |length| of theRange = 0 then return false
set theResult to anNSString's substringWithRange:theRange
return theResult as text
end returnFirstMatchOf:inThis:

on existsFirstMatchOf:theFind inThis:theString
set anNSString to current application's NSString's stringWithString:theString
set theRange to anNSString's rangeOfString:theString options:((current application's NSRegularExpressionSearch) + (current application's NSCaseInsensitiveSearch as integer))
if |length| of theRange = 0 then return false
return true
end existsFirstMatchOf:inThis:


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

 _______________________________________________
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: 
 >Email to Script Debugger or Script Editor (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Reading AppleScripts on iOS Device
  • Next by Date: Re: Reading AppleScripts on iOS Device
  • Previous by thread: Re: Email to Script Debugger or Script Editor
  • Next by thread: Reading AppleScripts on iOS Device
  • Index(es):
    • Date
    • Thread