[Quark] Problem with filename manipulation using "offset"

I counter one problem which I can’t figure out the solution.

My intention is to detect the first " " (space) on the Quark filename and then replaced with something else.

My sample script as follows:-

tell application "QuarkXPress Passport"
	activate
	tell document 1
		set theDocName to name
		set theLength to the length of theDocName
		set theOffset to the offset of " " in (every character of theDocName) as string
		set theFinalName to (characters (theOffset + 1) thru theLength of theDocName) as string
		display dialog theFinalName
		
	end tell
end tell

I received an Syntax Error “Can’t get " " in (every character of theDocName). Access not allowed.”

Please advise me on the correct syntax. Thanks!

Hi,

there are a few useless coercions e.g the result of offset is an integer and shouldn’t be coerced to text
try this, if you still get the error, it might be a terminology clash (Quark could have a word offset in it’s dictionary)


tell application "QuarkXPress Passport"
	activate
	tell document 1
		set theDocName to name
		set theOffset to the offset of " " in theDocName
		set theFinalName to text (theOffset + 1) thru -1 of theDocName
		display dialog theFinalName
	end tell
end tell

Thank you for your prompt reply, StefanK.

I tried your modified script but it still return me the same error.

Btw, I found from the Quark dictionary that “offset” is being used in 2 places:-

  1. offset (measurements point) : offset from the upper left corner of the picture box
  2. offset (integer, r/o) : index of the first character of this text within the story

From the error message received, it looks like Quark is treating my script as if “offset” is referring to the measurement instead of what I’m asking for.

Also, I found something else which I don’t understand also. If I were to take out some lines as shown below, it works perfect. Can you advise me again? Thanks!

(*
tell application "QuarkXPress Passport"
   activate
   tell document 1
*)
       set theDocName to " Test Job" --name
       set theOffset to the offset of " " in theDocName
       set theFinalName to text (theOffset + 1) thru -1 of theDocName
       display dialog theFinalName
(*
   end tell
end tell
*)

The easiest way is to put the offset line out of the application tell block


tell application "QuarkXPress Passport"
	activate
	tell document 1
		set theDocName to name
	end tell
end tell
set theOffset to the offset of " " in theDocName
set theFinalName to text (theOffset + 1) thru -1 of theDocName
display dialog theFinalName

Thank you, StefanK.

Yes, it returns the expected result now.

Now, I need to fine tune my script from your clue then.

Thanks!

P.S. I still like to know why Quark doesn’t support the syntax since its in its dictionary?

Because the offset command of Quark expects a different syntax. It is a property of a picture box or a story
You want to refer to the offset command of Standard Additions, which requires the two parameters of and in