4 Replies Latest reply on Aug 7, 2008 3:20 PM by Kevin Parrott

    [AS]  auto page number?

    Kevin Parrott Level 2
      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
        • 1. [AS] auto page number?
          sstanleyau Level 4
          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>
          • 2. Re: [AS]  auto page number?
            Kevin Parrott Level 2
            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
            • 3. [AS] auto page number?
              sstanleyau Level 4
              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>
              • 4. Re: [AS]  auto page number?
                Kevin Parrott Level 2
                Cheers for that Shane

                Kev