Hi everyone,
I am
trying to use search and replace in a QuarkXpress 6.5 document with a
AS.
Except for the
first occasion of search and replace all of the characters it has to replace are
replaced.
When I look in
the Eventslog I see that char 45 to 48 are found by the search command. But when
I count the characters in the QuarkXpress document then there is a difference of
1 character, I counted 46 to 49. At the end of the Eventslog I see that the get
command displays the 45 to 48 characters instead of the characters that I
counted.
Has anybody having any idea why the counting is wrong in only the
first occasion?
Below is the script I use and a part of the Eventlog.
Script:
(*
Search for the Quark
document
*)
set demodoc
to
(choose file with
prompt "Where is “cd_label”?" of type
{"XTMP", "XDOC"})
tell application
"Finder"
set demofolder
to
(container of
demodoc) as
text
end tell
tell application
"QuarkXPress Passport"
activate
open demodoc use doc
prefs «constant KPRFyes
»
(*
-- Import the list into the
first substory of the “cdlabel” story,
-- using the “cdlabel proto” prototype
story.
*)
import data from file (demofolder & "CDlabel.TXT")
¬
using prototype story "cdlabel proto"
into story "cdlabel" substory "first"
save document 1 in
file (demofolder & "CDlabel") without template
end tell
(*
-- Quark document is now created
-- Put all of the search and replace separately below
*)
set findText
to
"<BR>"
set replaceText
to
return
tell application
"QuarkXPress Passport"
set i
to
0 -- set the index to 0
tell story 1
of
current box
try
set foundLocations to
object reference of
every text
whose it
= findText
on
error number -1728
--
no more occurrences found
return ""
end try
end tell
set foundLocations to
the reverse
of
foundLocations
repeat with thisLocation
in
foundLocations
set theText
to
(contents of
thisLocation) as
text
considering case
if
theText is
findText then
set text
of
thisLocation to
replaceText
set i
to
i - 1 --
decrement index
end if
end considering
end repeat
end tell
Eventlog:
get object
reference of
every text
of
story 1 of
current box whose it
= "<BR>"
{text from character 45
to
character 48 of
text flow 1 of
text box 9 of
layout space "cd_label" of
project "CDlabel", text from character 62
to
character 65 of
text flow 1 of
text box 9 of
layout space "cd_label" of
project "CDlabel", text from character 181
to
character 184 of
text flow 1 of
text box 9 of
layout space "cd_label" of
project "CDlabel", text…. AND SO ON…..
The end of the
Eventlog says:
get text
from character 181
to
character 184 of
story 1 of
text box
9
of
layout space "cd_label" of
project "CDlabel"
"<BR>"
set every text
of
text from character 181
to
character 184 of
story 1 of
text box
9
of
layout space "cd_label" of
project "CDlabel" to
"
"
get text
from character 62
to
character 65 of
story 1 of
text box
9
of
layout space "cd_label" of
project "CDlabel"
"<BR>"
set every text
of
text from character 62
to
character 65 of
story 1 of
text box
9
of
layout space "cd_label" of
project "CDlabel" to
"
"
get text
from character 45
to
character 48 of
story 1 of
text box
9
of
layout space "cd_label" of
project "CDlabel"
"R<BR"
In the last line
there is R<BR instead of <BR> (the first “R” is the last character of
the previous word.
Who knows why AS or Quark cannot count correctly in
the first occurrence and in all of the other occasions the counting is
perfect???
Thanks in
advance,
Ed Wighman