Faster way to replace text in AppleWorks?
Faster way to replace text in AppleWorks?
- Subject: Faster way to replace text in AppleWorks?
- From: Dale Gillard <email@hidden>
- Date: Sun, 29 Sep 2002 21:40:52 +1000
Hi all
I have written a script that loops thru an AppleWorks document looking
for specific characters and replacing them eg ensuring a period/full
stop has a single space after it. As you can imagine, it takes quite a
while to do this even in a document of only a few hundred words.
Does anyone have any advice on how I could speed this up this process?
eg a 'you beaut' algorithm that's really fast at doing this rather than
my 'naive' algorithm.
Here's a snippet of the script so you can get an idea of what I'm doing:
------------------------------------------------------------------------
-
set space to " "
set CharCount to count of characters of front document
-- Start backwards to avoid loop variable being changed when a char is
added or removed.
repeat with aCharacter from CharCount to 1 by -1
-- If a comma or period is found
if character aCharacter of front document is comma or character
aCharacter of front document is period then
-- If 1 space does not follow it, add a space.
if character (aCharacter + 1) of front document is not space
then
make new character at character aCharacter of front document
with data space
end if
end if
end repeat
------------------------------------------------------------------------
-
Many thanks
Dale Gillard
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.