I want a BBEdit script available via the services menu. The script is to 
replace a term with a string containing the term.

Problem is that the following script (also enclosed) returns an Applescript 
error, having replaced the blanks in the original text in the text window. 
Apparently noBlanksName is not just a string of text, but still a reference 
to 'text of characters 1 thru 14 of text document 1', so the replace 
command operates on the original document, not a local string.

What stupid AppleScript/BBEdit trick am I missing?

John

*tell* *application* "BBEdit"

*tell* *text* *of* *text window* 1

 *set* foundStr *to* *find* "(.*)$" options {search mode:grep, starting at 
top:true}

 *if* (found *of* foundStr) *then*

 *display dialog* "the found text is " & (found text *of* foundStr)

 *set* theFoundText *to* (found text *of* foundStr) *as* *text*

 *set* noBlanksName *to* theFoundText *as* *text*

*replace* " " using "" searching in noBlanksName

 *display dialog* "noBlanksName is " & noBlanksName & "  Result is " & 
result

 *set* *text* *of* (found object *of* foundStr) *to* "[" & theFoundText & 
"|http://mmisw.org/ont/ooici/ooiionroles/"; & noBlanksName & "]"

 -- set result to text of (found object of foundStr)

 *end* *if*

*end* *tell*

*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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Attachment: ExtendRoleWithConfluenceORRLink.scpt
Description: Binary data

Reply via email to