Thank you very much Chris. I'll check this one when I've completed my "scratch window" thing for SD...
Jean-Christophe > On Apr 17, 2017, at 7:20, Christopher Stone <[email protected]> > wrote: > > On 04/15/2017, at 18:27, Jean-Christophe Helary > <[email protected] <mailto:[email protected]>> > wrote: >>> This job can also be handled nicely by AppleScriptObjC these days: >> >> Yeah :) >> >> This is really ugly :) But I guess that's a place from where I can start >> getting things done with ASObj-C... > > > Hey Jean-Christophe, > > You can always use a traditional handler-call instead of an interleaved one. > > ------------------------------------------------------------------------------ > use AppleScript version "2.4" > use framework "Foundation" > use scripting additions > ------------------------------------------------------------------------------ > > set pathString to " /path/to/my file.stuff " > set newStr to cngStr("^\\s*|\\s*$", "", pathString) > > ------------------------------------------------------------------------------ > --» HANDLERS > ------------------------------------------------------------------------------ > on cngStr(findStr, replaceStr, dataStr) > set anNSString to current application's NSString's > stringWithString:dataStr > set dataStr to (anNSString's stringByReplacingOccurrencesOfString:findStr > withString:replaceStr ¬ > options:(current application's NSRegularExpressionSearch) range:{0, > length of dataStr}) as text > end cngStr > ------------------------------------------------------------------------------ > > You can also tuck your hander into a library, so all you see in your working > script is something like this: > > ------------------------------------------------------------------------------ > use fLb : script "fLb" > > set pathString to " /path/to/my file.stuff " > set newStr to fLb's cngStr("^\\s*|\\s*$", "", pathString) > ------------------------------------------------------------------------------ > > In this case the library is: > > ~/Library/Script Libraries/FLb.scptd > > Personally I'll continue to use the Satimage.osax until its dying day. 14 > years and counting... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/bbedit.
