I am working on a series of books about slavery. I imported records (35.000) from an Excel database to Filemaker and export this as text with x-Tags. Than I let an Applescript perform some changes in texEdit before I import it in Quark 6.
The books contains hundreds of pages with an alphabetical list of the slaves who where set free in 1863.
Looks like this: 3430 Aardenberg, George Voorspoed | George
m 9 Oningevuld rc pe929 Zoon van Cornelia en broer van Louis en Christiaan. Op 30–12–1861 de naam Aardenburg als mn gegeven.
[…] Lots of other names […]
3417 Advids, Eduard Marinus | Eduard
m 5 rc pe170 Verwant aan Evailloe Maria Advids; bron geeft niet aan hoe. Vermoedelijk verwant aan de in Paramaribo op 01–07–1863 geëmancipeerde Martinus Marius Advids.
On every page I want to place the first two characters of the first and last record (=name) in the margin of a page.
So, for this example it will be Aa | Ad.
The page layout contains two linked text boxes for the columns and all the text is tagged with stylesheets.
Is there a way to do this by applescript and how? I know how to work with text offset, but how do I refer to the last record of the second box? You can find two sample pages here.
Any help or suggestions would be great. Thanks.
Kjeld
Ok. I am almost there after two days of scripting. Who is going to help me figure out the last part?
Below is a part of the code which picks out the characters of the first name. Works fine. For the second name it only works if the paragraph is not completely on the current page (so 1 or more lines are on the next page).
How do I really grap the first character of the last paragraph with a specific stylesheet?
tell application "QuarkXPress Passport"
tell document 1
set pg to name of page pageX
set pageX to pg
show page pageX
tell page pageX
--Get first reference
tell text box "textBox1"
try
set firstCharPos_1 to ((offset of (first character whose character style is "2F")) + 1)
set secondCharPos_1 to (firstCharPos_1 + 1)
tell story 1
set firstCharRef_1 to (a reference to character firstCharPos_1)
set secondCharRef_1 to (a reference to character secondCharPos_1)
set ref1_1A to contents of firstCharRef_1
end tell
end try
end tell
--get second reference
tell text box "textBox2"
-- try
set lastPar to index of last paragraph
--The next line gives an error:
set firstCharPos_2 to ((offset of (first character of paragraph lastPar) whose character style is "2F") + 1)
set secondCharPos_2 to (firstCharPos_2 + 1)
tell story 1
set firstCharRef_2 to (a reference to character firstCharPos_2)
set secondCharRef_2 to (a reference to character secondCharPos_2)
set ref2_1A to contents of firstCharRef_2
end tell
-- end try
end tell
end tell
end tell
end tell
I’m not running qx6, but in previous versions you can refer to the paragraphs of a text box directly, not “story 1”. So you could refer to “paragraph lastParagraph of text box “textbox”” and get the first two characters.
Thanks for the reaction. I solved the problem. Now I am referring to the offset of the text Style ranges of the names in “TextBox2”. This gives me a list with the firstcharacterpositions in story 1of the names in a textbox.
Working with paragraph last paragraph doesn’t seem to work smoothly. If the last character of TextBox2 is a ¶ (=paragraph), it can’t get the right characters. Here you can find the way it’s solved now.