Thanks for the suggestion Mark. Unfortunately, that generates the same error--"Can't set text 23 thru 32 of theText...etc." RJay On Sep 18, 2008, at 2:54 PM, Mark J. Reed wrote: > If theText is > > Here's some text with underscores (_like this_). > > Then the first underscore is at text position 36, but is contained > within word 6. I'm guessing that beginItal holds the former value, > not the latter, so you want "set text beginItal thru endItal of > theText", not "set words ...". (Setting words would also replace the > entire words "(_like" and "this_)" rather than leaving the parentheses > alone.) > > On Thu, Sep 18, 2008 at 3:16 PM, RJay Hansen > <[log in to unmask]> wrote: >> I'm writing a script that's intended to parse out text that is >> enclosed >> within underscores (_like this_). I'm using Tex-Edit Plus and Smile. >> >> I'm putting text selected in Tex-Edit Plus into a variable then >> getting what >> I need working with the text in the variable. Once I have it, I >> want to >> replace the string surrounded by the underscores (and including the >> underscores) with the new string using this: >> >> set words beginItal thru endItal of theText to newString >> >> beginItal and endItal are the indexes of the underscores. theText >> is the >> variable that the selection from the document is read into and >> newString is >> of course, the replacement string. >> >> Smile comes back with "Can't set words 23 thru 32 of theText (it >> puts the >> actual string in the error message/not the variable name as shown >> here) to >> newString (and again, it puts the new string in the error message, >> not the >> variable name)". >> >> I haven't been able to figure out why I can't do this. Any help >> would be >> appreciated. >> >> Thanks, >> >> RJay >> > > > > -- > Mark J. Reed <[log in to unmask]>