Re: Replace with different text or by using counter
Re: Replace with different text or by using counter
- Subject: Re: Replace with different text or by using counter
- From: Paul Skinner <email@hidden>
- Date: Mon, 20 May 2002 14:51:51 -0400
You didn't like my previous suggestion?
On Thursday, May 16, 2002, at 09:58 PM, Paul Skinner wrote:
--begin script
set storyText to "Once upon a time there lived in a certain village a
little girl, LIBRARYNAME the prettiest creature that ever was seen;
LIBRARYNAME she was loved and admired by all, not one in LIBRARYNAME
the village could compare with her. Her mother was fond of her to a
great degree, LIBRARYNAME and her grandmother much more so; and well
they might, she was so good-natured, LIBRARYNAME so sweet of temper,
and so ready to oblige; LIBRARYNAME and, besides, never missed her
prayers twice or thrice a day for her mother, and all her relations,
and every body else she could think of. LIBRARYNAME It being cold
weather, her grandmother had a little red riding-hood made for her to
keep her warm and she looked so very pretty LIBRARYNAME and pleasant
when she had it on, that by every body she soon gained LIBRARYNAME the
name of Little Red-Riding-Hood."
ReplaceAndEnumerate(storyText, "LIBRARYNAME", "FG")
on ReplaceAndEnumerate(inputText, originalText, replacementText)
set inputList to ListFromText(inputText, originalText)
set output to {item 1 of inputList}
repeat with iteration from 2 to the length of inputList
set the end of output to (replacementText & iteration - 1 &
item iteration of inputList) as text
end repeat
return output as text
end ReplaceAndEnumerate
on ListFromText(inputText, TID)
set AppleScript's text item delimiters to TID
set inputList to every text item of the inputText
set AppleScript's text item delimiters to ""
return inputList
end ListFromText
--end script
-->"Once upon a time there lived in a certain village a little girl,
FG1 the prettiest creature that ever was seen; FG2 she was loved and
admired by all, not one in FG3 the village could compare with her. Her
mother was fond of her to a great degree, FG4 and her grandmother much
more so; and well they might, she was so good-natured, FG5 so sweet of
temper, and so ready to oblige; FG6 and, besides, never missed her
prayers twice or thrice a day for her mother, and all her relations,
and every body else she could think of. FG7 It being cold weather, her
grandmother had a little red riding-hood made for her to keep her warm
and she looked so very pretty FG8 and pleasant when she had it on, that
by every body she soon gained FG9 the name of Little Red-Riding-Hood."
Or do you HAVE to have the text replacement done directly in QXP?
On Thursday, May 16, 2002, at 05:50 PM, Elmer Banate wrote:
Hi to all,
I need to replace the word "LIBRARYNAME" in my quark document to the
name of
items in the library I created.
The script must replace not one replace string. example "LIBRARYNAME"
will
be replaced to "FG01" after replacing the first word ("LIBRARYNAME") in
the
next replace is "FG02" and soon, depending on how many occurrences, if
"LIBRARYNAME" occurred 22 time the last replacement text is "FG22".
I'm trying to use counter but my counter doesn't work.
I suspect the my problem is around here:
set (every text of stories where it is search_string) to replace_string
--------
tell application "QuarkXPress 4.11"
set FigName to "FG0"
tell document 1
try
set LibName to every text of every story where it is
"LIBRARYNAME" as list
end try
set ctr to 1
repeat with i from 1 to the number of items in LibName
set search_string to item i of LibName
set replace_string to FigName & ctr as string
try
set (every text of stories where it is search_string) to
replace_string
set ctr to ctr + 1
end try
end repeat
end tell
end tell
TIA
Regards
elmer
--
Paul Skinner
_______________________________________________
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.