Hallo Michael,
doch, doch, die Einfügemarke ('insertion point') kann man immer noch ansprechen. Allerdings braucht es dazu spezielle, gymnastische "Verrenkungen".
Nachstehend die erweiterte Version des Offset-Feststellen-Scripts, welches sowohl mit ausgewählten Textketten als auch blinkendem Cursor fertig wird.
Zuerst Grundlegendes:
A) Wenn eine Textkette ausgewählt ist, dann ist das Ergebnis aus 'object reference of first character of selection' immer im Format …
Davon muss man [b]immer die Zahl '1' abzählen, wenn man als Resultat den 'offset'-Wert wünscht.
B) Wenn hingegen nur der Cursor blinkt, dann ist das Ergebnis aus 'object reference of selection' [b]meistens im Format …
Wenn der Cursor ganz am Anfang der Story blinkt dann ergibt dies …
Man muss sich also auch danach erkundigen, ob das Resultat 'after' oder 'before' enthält und bei 'before' die Zahl '1' abziehen. Im nachfolgenden Script wird die Variable 'compVal' entsprechend vorbereitet.
Ob Textkettenauswahl oder Position des Cursors: In beiden Fällen wird zuerst eine Fehlermeldung provoziert, damit die Objektreferenz in einen String verwandelt wird, aus welchem man dann mit gütiger Hilfe der Satimage-OSAX den Offset-Wert ausziehen kann.
---
tell application "QuarkXPress 6.1"
tell document 1
if tool mode is not contents mode then set tool mode to contents mode
set boxCount to count (every text box whose selected is true)
if boxCount = 1 then
tell selection
set selCount to count of characters
end tell
if selCount = 0 then
set objRef to object reference of selection
try
set insPoint to (find text "[0-9]+" in objRef)
on error errMsg
try
if errMsg contains "after" then
set compVal to 0
else
set compVal to 1
end if
set insPoint to ((item 1 of (find text "[0-9]+" in errMsg with all occurrences, string result and regexp)) - compVal) as integer
end try
end try
else
try
set objRef to (object reference of first character of selection)
on error
display dialog "Keine Auswahl vorhanden!" buttons "OK" default button 1 with icon 2
error number -128
end try
try
set insPoint to (find text "[0-9]+" in objRef)
on error errMsg
try
set insPoint to (item 1 of (find text "[0-9]+" in errMsg with all occurrences, string result and regexp)) - 1
end try
end try
end if
else if boxCount = 0 then
display dialog "Es ist keine Texbox ausgewählt." buttons "OK" default button 1 with icon 2
error number -128
else if boxCount > 1 then
display dialog "Nicht mehrere Boxen aufs Mal auswählen." buttons "OK" default button 1 with icon 0
end if
end tell
end tell
---
Hans Haesler <hsa@ringier.ch>