1 Reply Latest reply on Nov 19, 2014 2:51 PM by ophello

    Multiple conditional using AppleScript in Indesign — won't work?

    ophello Level 1

      When I enter in a height and width of, say, 5 inches, it returns with a build size that doesn't make sense, according to the logic gate I built. Here's a stripped-down snippet of the code I wrote that should work in InDesign CS6. Any help would be greatly appreciated.


       

      tell application "Adobe InDesign CS6"

      activate

       

      set myDoc to active document

      set origLevel to user interaction level of script preferences

      set user interaction level of script preferences to interact with all

       

      set myDialog to make dialog with properties {name:"Make Template", can cancel:true}

      tell myDialog

      tell (make dialog column)

      tell (make border panel)

      tell (make dialog column)

      make static text with properties {static label:"Width:", min width:60}

      make static text with properties {static label:"Height:", min width:60}

      make static text with properties {static label:"Bleed:", min width:60}

      end tell

      tell (make dialog column)

      set myWidth to make text editboxes with properties {edit contents:"", min width:60}

      set myHeight to make text editboxes with properties {edit contents:"", min width:60}

      set myBleed to make text editboxes with properties {edit contents:"", min width:60}

      end tell

      tell (make dialog column)

      make static text with properties {static label:"in", min width:0}

      make static text with properties {static label:"in", min width:0}

      make static text with properties {static label:"in", min width:0}

      end tell

      tell (make dialog column)

      make static text with properties {static label:"", min width:25}

      end tell

      end tell

      end tell

      end tell

       

      set userResponse to show myDialog

      if userResponse is true then

      set docWidth to edit contents of myWidth as string

      set docHeight to edit contents of myHeight as string

      set docBleed to edit contents of myBleed as string

      destroy myDialog

      else

      destroy myDialog

      error number -128

      end if

       

      set bigDim to docWidth as string

      if docHeight > docWidth then

      set bigDim to docHeight as string

      end if

       

      set buildSize to 1

      if bigDim > 216 and bigDim ≤ 432 then

      set buildSize to 2

      else if bigDim > 432 and bigDim ≤ 864 then

      set buildSize to 4

      else if bigDim > 864 and bigDim ≤ 2160 then

      set buildSize to 10

      end if

       

      set newWidth to (docWidth / buildSize)

      set newHeight to (docHeight / buildSize)

      set newBleed to (docBleed / buildSize)

       

      tell myDoc

      set document bleed top offset of document preferences to newBleed

      set page width of document preferences to newWidth

      set page height of document preferences to newHeight

      end tell

      set user interaction level of script preferences to origLevel

      end tell