2 Replies Latest reply on Feb 28, 2013 8:47 AM by Luke Hodsdon

    [AS] Moving copied text to the end of a Text frame with Applescript?

    Luke Hodsdon

      I'm trying to run an IF statement that eventually will check for 3 wild card characters (@,—," - ") and then copy that paragraph information into the end of another textbox that my script is also creating.

       

      Here's a snippet of what i'm stuck on...

      tell application "Adobe InDesign CS5"

                repeat with i from 1 to (count of paragraphs)

                          try

                                    tell paragraph i

                                              set ThePage to my get_CurrentPage()

                                              try

        (*Check for wildcard " - "*)

                                                        if it contains " – " then

                                                                  set applied paragraph style to "AD SIZE"

                                                                  set Ad_Size to contents

                                                                  set {This_Width, This_Height} to {"", ""}

                                                                  repeat with This_Ad in Ad_Props

                                                                            if Ad_Size contains (Ad_Label of This_Ad) then

                                                                                      set This_Width to Ad_Width of This_Ad

                                                                                      set This_Height to Ad_Height of This_Ad

                                                                                      exit repeat

                                                                            end if

                                                                  end repeat

                                                                  set Ad_Box to my Make_Box(ThePage, {1.875, 10.875, This_Height + 1.875, This_Width + 10.875})

        duplicate contents to (insertion point -1 of Ad_Box)

       

       

        (*Check for wildcard "—"*)

                                                        else if it contains "—" then

                                                                  set applied paragraph style to "AD REP"

        duplicate contents to (insertion point -1 of Ad_Box)

       

       

        (*Check for wildcard "©"*)

                                                        else if it starts with "©" then

                                                                  set applied paragraph style to "AD PLACEMENT"

        delete (character 1)

        duplicate contents to (insertion point -1 of Ad_Box)

       

       

                                                        else

        duplicate contents to (insertion point -1 of Ad_Box)

       

                                                        end if

                                              end try

                                    end tell

                          on error errmsg number errnum

                                    display dialog "There has been an error " & "[" & i & "] (" & errmsg & " [" & errnum & "])" buttons {"Okay"} default button 1 with icon stop

                          end try

                end repeat

       

      end tell

       

      The whole script makes the boxes like I need, but it's not moving the content to the Ad_Box. I think the problem is here:

        duplicate contents to (insertion point -1 of Ad_Box)

      But I can't figure out the right script. Racking my brain all day. Any help would be greatly appreciated!!

       

      Here's a block of text i'm using this with if it helps to visualize it:

      1/4 –

      Ad Name

      P/U—SW

      ©12

       

      FULL –

      Ad Name

      C/R—SW

      ©9

       

      FULL –

      Ad Name

      C/R—SW

      ©5

       

      Message was edited by: Luke Hodsdon (fixed coding & spelling mistakes)