> Right. I explained that already. Perhaps my explanation wasn't clear? No it was fine. It just took a bit to sink in ;-)
> I also explained that the major problem remaining is that clippings EAT > trailing whitespace even if they themselves CONTAIN whitespace. That takes a > little working around; the script appended does so. I ran into something that must have been that in one of my attempts. I REALLY appreciate your appended script. I'm reading through it now to see if I can sort out what it's doing. The language constructs are foreign to me, but I should be able to puzzle through the logic. Thanks again, v On Aug 23, 9:34 am, Christopher Stone <listmeis...@thestoneforge.com> wrote: > On Aug 22, 2011, at 17:20, verdonv wrote: > > > After looking through the BBEdit script library, I realize the problem is > > that the 'replace' actually returns an integer that represents the number > > of instances of the pattern changed, and not the changed string. > > Right. I explained that already. Perhaps my explanation wasn't clear? > > > I know it seems silly, but given this, and the way that Clippings work, I > > think I'll have to fudge this so that the applescript does the replace on > > the selection, then copies the modified selection and returns it to the > > clipping, so the clipping can insert it... > > I also explained that the major problem remaining is that clippings EAT > trailing whitespace even if they themselves CONTAIN whitespace. That takes a > little working around; the script appended does so. > > > Anyways, this is an applescript question and not a BBEdit question, so I'll > > take the discussion to a more appropriate forum. > > Any questions about scripting BBEdit are appropriate to this forum. > > -- > Best Regards, > Chris > > ------------------------------------------------------------------------ > tell application "BBEdit" > try > tell front text window > tell text of selection > replace "(\\w+)" using ¬ > "[\\1]" options {search mode:grep, case sensitive:false} > set selText to its contents > set chrOfst to its characterOffset > set selLen to its length > set selLen2 to selLen > end tell > repeat while selText ends with return > set selText to text 1 thru -2 of selText > set selLen to selLen - 1 > end repeat > if selLen2 ≠ selLen then > select (characters chrOfst thru (chrOfst + selLen - 1)) > end if > set sel to contents of text of selection > return sel > end tell > on error errMsg number errNum > set sep to "==============================" > set e to sep & return & "Error: " & errMsg & return & sep & return ¬ > & "Error Number: " & errNum & return & sep > beep > display dialog e > end try > end tell > ------------------------------------------------------------------------ -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>