Fwd: Replacing in TextEdit
Fwd: Replacing in TextEdit
- Subject: Fwd: Replacing in TextEdit
- From: Paul Robinson <email@hidden>
- Date: Sat, 25 Sep 2004 13:38:19 +0100
Sorry - meant to send this to the list.
P.
Begin forwarded message:
From: Paul Robinson <email@hidden>
Date: 25 September 2004 13:36:14 BST
To: "Vince E." <email@hidden>
Cc: Paul Robinson <email@hidden>
Subject: Re: Replacing in TextEdit
Well, you could try
--code begins
tell application "TextEdit"
set test_str to text of document 1
set AppleScript's text item delimiters to "open"
set test_items to text items of test_str
set AppleScript's text item delimiters to "close"
set final_str to test_items as text
set text of document 1 to final_str
end tell
--code ends
This works for plain text, and replaces all instances of 'open' with
'close'. It will also work for rtf files, but you would have to have a
loop that works its way through each attribute run, saves text font,
size and colour. Then manipulates the text as above, and adds back in
the formatting before displaying the new text. Might be slow for long
pieces of text with frequent format changes.
HTH
P.
On 25 Sep 2004, at 10:16, Vince E. wrote:
That's easy! - But what if the piece of text you are going to replace
is neither a word nor a character or a paragraph?
What if it is a part of a word like the 'bag' of 'handbag' you want
to change into 'foot'? - just for example!
I want the user to be able to type any text into a text field he/she
wants to be replaced
so I need a more general specification than word, character or
paragraph but I just don't know how to name it
Thanx Vince
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden