3 Replies Latest reply on Jul 14, 2011 9:07 AM by JJ0330

    AppleScript InDesign CS5.5 Syntax Error

    JJ0330 Level 1

      Hi, this script runs fine as is but when I got to edit, it gives me error when compiling.  Error I get is on following 2 lines with as text part.  If I take it out, I don't get error but script doesn't run.  Script was created on a older version of MAC OS and InDesign but someone else.

       

      set contents of myTextFrame to TheList as text

       

      set XML_File to (choose file with prompt XMLstr) as text

       

       

      Error is Syntax error:" Expected end of line, etc. but found application constant or consideration."

       

      Here is complete script:

       

       

      try

      set CSVstr to "Please locate your CSV file..."

      set CSV_File to (choose file with prompt CSVstr) as text

      set csvData to read file CSV_File

       

      set csvEntries to paragraphs of csvData

       

      set {CSVItem1} to parseCsvEntry(csvEntries's item 1)

      set {CSVItem2} to parseCsvEntry(csvEntries's item 2)

      set {CSVItem3} to parseCsvEntry(csvEntries's item 3)

      set {CSVItem4} to parseCsvEntry(csvEntries's item 4)

      set {CSVItem5} to parseCsvEntry(csvEntries's item 5)

      set {CSVItem6} to parseCsvEntry(csvEntries's item 6)

      set {CSVItem7} to parseCsvEntry(csvEntries's item 7)

      set {CSVItem8} to parseCsvEntry(csvEntries's item 8)

      set {CSVItem9} to parseCsvEntry(csvEntries's item 9)

       

      set TheList to {CSVItem1, CSVItem2, CSVItem3, CSVItem4, CSVItem5, CSVItem6, CSVItem7, CSVItem8, CSVItem9}

       

      tell application "Adobe InDesign CS5.5"

      set myDocument to active document

      tell XML view preferences

      set show attributes to false

      set show structure to true

      set show tagged frames to false

      set show tag markers to false

      set show text snippets to true

      end tell

      tell XML import preferences

      set allow transform to false

      set create link to XML to false

      set ignore unmatched incoming to true

      set ignore whitespace to true

      set import CALS tables to true

      set import style to merge import

      set import text into tables to false

      set import to selected to false

      set remove unmatched existing to false

      set repeat text elements to true

      end tell

      set myPage to active page of active window

      tell myPage

      set myTextFrame to make text frame

      set geometric bounds of myTextFrame to {"6p", "6p", "24p", "24p"}

       

      ****Error on below line ****

      set contents of myTextFrame to TheList as text

      ****************************

      move myTextFrame to {"-30p", 0}

      end tell

       

      set Char1 to item 1 of TheList

      set Char2 to item 2 of TheList

      set Char3 to item 3 of TheList

      set Char4 to item 4 of TheList

      set Char5 to item 5 of TheList

      set Char6 to item 6 of TheList

      set Char7 to item 7 of TheList

      set Char8 to item 8 of TheList

      set Char9 to item 9 of TheList

      set AppleScript's text item delimiters to "\"\""

      set {LTry} to Char1's text items

      set AppleScript's text item delimiters to {}

       

      set placedAsset to place asset asset LTry of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {0.363, 0.84}

      set placedAsset to place asset asset Char2 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {3.695, 0.84}

      set placedAsset to place asset asset Char3 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {6.905, 0.84}

      set placedAsset to place asset asset Char4 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {0.363, 3.91}

      set placedAsset to place asset asset Char5 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {3.695, 3.91}

      set placedAsset to place asset asset Char6 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {6.905, 3.91}

      set placedAsset to place asset asset Char7 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {0.363, 6.95}

      set placedAsset to place asset asset Char8 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {3.695, 6.95}

      set placedAsset to place asset asset Char9 of library "JetroXMLElements.indl" on myDocument

      move placedAsset to {6.905, 6.95}

      tell myDocument

      set XMLstr to "Please locate your XML file..."

      ****Error on below line ****

      set XML_File to (choose file with prompt XMLstr) as text

      ****************************

      import XML from XML_File

      end tell

      tell application "Adobe InDesign CS5.5"

      set find text preferences to nothing

      set change text preferences to nothing

      set find what of find text preferences to "mykzlplx"

      set change to of change text preferences to ""

      tell active document

      change text

      end tell

      set find text preferences to nothing

      set change text preferences to nothing

      set find what of find text preferences to "¬"

      set change to of change text preferences to ""

      tell active document

      change text

      end tell

      set find text preferences to nothing

      set change text preferences to nothing

       

      end tell

       

      end tell

      end try

      to parseCsvEntry(csvEntry)

      set AppleScript's text item delimiters to "\"\""

      set {Stuuff} to csvEntry's text items

      set AppleScript's text item delimiters to {""}

      return {Stuuff}

      end parseCsvEntry

      Thanks!

        • 1. Re: AppleScript InDesign CS5.5 Syntax Error
          Muppet Mark Level 5

          I don't have 5.5 but the code compiles just fine in 5 if I replace your '*' with '-'. Use double hyphen for your comment… The 'similar' line up at the top of your script NO error? If so then I would suspect a clash of the terms 'as text' ID will have it's own definition of this in side of the app tell block you could try change that to 'as string' the result is the same and ID may not have this term…

          • 2. Re: AppleScript InDesign CS5.5 Syntax Error
            SuperMacGuy Level 2

            if you changed this error line:

            set XML_File to (choose file with prompt XMLstr) as text

             

            to not be "as text" it may work; use "as string" instead

            set XML_File to (choose file with prompt XMLstr) as string

             

            "as text" may be be doing some encoding (utf?) but string may be "cleaner"? Also, in the very first "choose file" on line 3 you are not calling that within the InDesign context, so it's OK, but the other 2 are inside of InDesign and sometimes InDesign (or other apps) don't seem to handle a few commands properly like either the raw script or Finder will (I have found InDesign can't round 3.6 to 4 etc).

            Or maybe just leave off the coersion, and you should get a file alias. Will that import properly in the next line?

            FWIW, Photoshop CS5 (12.0) had a bad file name to alias bug (fixed in 12.0.1), maybe this is similar?

             

            Chris

            • 3. Re: AppleScript InDesign CS5.5 Syntax Error
              JJ0330 Level 1

              Thanks, I had re-written and seem to have it working ok but went back to original to test using string instead of text and that seems to work.

               

              Thanks again for the help.

               

              Joe