Search and Replace?

I know this should be pretty easily done in AS, but I haven’t tinkered much with AS in a long time (especially X) - and I have now forgotten most everything I knew from OS8-9.

Here’s what I am attempting to do (10.2.8; Appleworks 6) - I would like to select an item (word, paragraph, line… whatever) and then run the AS, returning the result wrapped in quotes.

Thanks, in advance, for any help you may have to offer.


Hello hopster,

I have only been scripting for about a year (–and LOVING it!!–), so admittedly I qualify as somewhat of a newbie, but, it seems to me as though doing a search & replace in Appleworks would be simpler for text which you have selected than involving Applescript in the process. Again, I stress that this is only my opinion as a newbie, but it seems as if you’re trying to run over a peanut with a Cadillac–unless, of course, there is something further you wish to do with applescript which you have not stated. Nevertheless, if you will take my advice, do a search on this site for some keyword like, “Appleworks”, or “search/replace”, etc…

I hope this helps.

Sincerely (and with no offense intended),

Variable as the shade

Variable as the shade -

Thanks for the reply, but… doing a search/replace isn’t quite what I’ve got in mind. I do a lot of writing and editing for public speaking - so I’d like to be able to go back in my manuscript and upon review select a word or a phrase or even a paragraph and give it emphasis by putting it in quotes or maybe setting it off with asterisks, or whatever. A find/replace function means I must know the specific term. That isn’t quite what I would like to do.

Perhaps this will help clarify what I’ve got in mind and what I’m seeking to do. -Oh, and then, once I’ve got my 'script worked out, I can assign it to a key combination and do the “emphasizing” (just like that!) on the fly without having to mouse up to the AS menu.

Thanks much,

(by the way, I’m ready to jump off the sinking ship known as Nisus Writer - but anyway - they had in their 6.5/below and now even in their sadly hobbled X version this very functionality. They used MacPerl. I edited those scripts to give any number of combinations. I just can’t seem to get it right with AppleScript. If I remember correctly, does it have something to do with the TID’s?)

Hi Hopster,

you can use this little script:

tell application "AppleWorks 6"
set mySelection to selection of document 1if class of mySelection = string thenset selectedText to """ & mySelection & """
set selection to selectedTextend ifend tell

If you use iKey, you can assign a shortcut to the script.

Thank you, thank you, thank you! That does exactly what I’m looking for! (I forgot about the “class of” bit in my attempts.)

Thanks again!