insert a discretionary return

Discuss scripting using AppleScript in QuarkXPress 2015, 2016, 2017 & 2018.
Discuss scripting using JavaScript in QuarkXPress 2018.
Post Reply
chandlerbing
Posts: 272
Joined: 12 Oct 2004, 14:01

insert a discretionary return

Post by chandlerbing » 26 Nov 2018, 18:29

I've been trying for hours to find even the basic information I need to make this script, and just can't come up with it. Is it possible to create an applescript that will replace every instance of "/" in my selected text with the slash plus a discretionary return (option-\)?

Jean-Marie Schwartz
Posts: 1170
Joined: 23 Nov 2004, 04:30

Re: insert a discretionary return

Post by Jean-Marie Schwartz » 27 Nov 2018, 03:21

Hi! Give this a try:

Code: Select all

property DiscRet : character id 7 --«data utxt0007» as Unicode text -- U+0007; 7

tell application "QuarkXPress9"
	tell document 1
		tell story 1 of current box
			set every text where it is "/" to DiscRet
		end tell
	end tell
end tell
HTH.
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.5 • QuarkXPress 9.5.4.1 + QuarkXPress 2017 • Adobe CS5 =

chandlerbing
Posts: 272
Joined: 12 Oct 2004, 14:01

Re: insert a discretionary return

Post by chandlerbing » 27 Nov 2018, 12:45

Thanks. That's closer, but not quite what I need. I need to keep the slash and also have a discretionary return. This version (below) using the unicode you provided works except it's using soft returns, not discretionary returns. I can't find the correct code for a discretionary return or I think it would work. (BTW, in my original post I typed the WRONG keystroke for the discretionary return. Brain fart. I meant command-return for the discretionary return)

property DiscRet : character id 7 --«data utxt0007» as Unicode text -- U+0007; 7

tell document 1 of application "QuarkXPress"
tell selection
set every text where it is "/" to "/" & DiscRet
end tell

end tell

chandlerbing
Posts: 272
Joined: 12 Oct 2004, 14:01

Re: insert a discretionary return

Post by chandlerbing » 27 Nov 2018, 13:15

I think I figured it out. With a bit more research I discovered that the discretionary return in Quark is technically a "zero-width space." Found the code for that and this script now works.

Code: Select all

tell document 1 of application "QuarkXPress"
	tell selection
		set every text where it is "/" to "/" & {character id 8203}
	end tell
	
end tell

Jean-Marie Schwartz
Posts: 1170
Joined: 23 Nov 2004, 04:30

Re: insert a discretionary return

Post by Jean-Marie Schwartz » 28 Nov 2018, 05:17

Sorry for the misunderstanding.
Wonderful how you dealt with it! Congrats and enjoy!
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.5 • QuarkXPress 9.5.4.1 + QuarkXPress 2017 • Adobe CS5 =

Post Reply

Return to “QuarkXPress 20xx: Scripting (AppleScript / JavaScript)”