Skip to main content
Inspiring
August 7, 2008
Question

[AS] auto page number?

  • August 7, 2008
  • 4 replies
  • 430 views
Hi

Im trying to get page numbers returned using the below code, the number returned is supposed to go into a text frame,
but all i keep getting in the text frame is this «constant nSPcSApn, , I have two pages so would have expected pageNum on
page 1 to be "1" and pageNum on page 2 to be "2", any ideas why this is happening or how I can fix this wee glitch?

set pageNum to auto page number
set mySlug to make text frame with properties {contents: docName & "Page:" & " " & pageNum}

cheers
Kev
This topic has been closed for replies.

4 replies

Inspiring
August 7, 2008
It actually depends a bit on what version of the OS you use. Pre-Leopard,<br />you could use:<br /><br /> set contents to "Page <0024>"<br /><br />and the stuff between < and > would be recognised as code for a character.<br />However, Leopard uses Unicode all the time, so that no longer works.<br />Instead, you can use the new id property of text, like this:<br /><br /> set contents to ("Page " & character id 24)<br /><br />If you need something that will work with either, you can use this method:<br /><br /> set contents to "Page " & «data utxt0018» as Unicode text<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
Inspiring
August 7, 2008
Cheers for that Shane

Kev
Inspiring
August 7, 2008
Hi Shane

cheers for the explanation, appreciated, I am using ID CS3 5.0.3, out of interest could you please explain a wee bit more about using (ASCII code 24) ?

cheers
Kev
Inspiring
August 7, 2008
You can't use enumerations for characters except by themselves. What's<br />happening with your code is that AppleScript is trying to concatenate some<br />strings plus an enumeration; it can only do that by coercing the enumeration<br />to text, which returns the code you see.<br /><br />So you need to either use two steps:<br /><br />set mySlug to make text frame with properties {contents: docName & "Page:"<br />& " "} <br />set contents of insertion point -1 of parent story of mySlug to auto page<br />number<br /><br />Or use the code for auto page number (ASCII code 24) -- how you do that<br />depends on the version of InDesign.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>