Author Topic: Script quit working after the upgrade  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

Offline Mark Lane

  • Visitor
  • Posts: 3
  • Karma: 0
Script quit working after the upgrade
« on: May 14, 2010, 08:11:29 AM »
I have a script that formats the text, makes picture box, get the image, and then places it in the text box above each product description. But after the upgrade to my Mac OS to 10.6.3 and the upgrade to Quark 8 it quit working. I think I have three issues with the script. Since I don't work apple scripting very often and I'm not a programmer, I having problem fixing it.
1) this one show an error in the event log history.
set selected of paragraph 3 of story 1 of text box 2 of document "quark test2" to true
        --> error number -1728

my code:
set selected of paragraph (CurrentParagraphNumber + 1) to true
2) quark locks up on this one.
error "QuarkXPress got an error: Connection is invalid." number -609

my code:
tell before word 1 of paragraph 1
                                    set contents to (return & "*")
                                end tell
3) I don't know what's up with this one, it works sometimes depending were you have your cursor when you start your script.
set CurSel to object reference of selection

I hope this is a simple fix.
Any help would be appreciated.
Thanks,
Mark Lane


Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Re: Script quit working after the upgrade
« Reply #1 on: May 14, 2010, 10:49:03 AM »
Hi Mark and welcome to these forums!

Can you post the whole script? It is very hard to what is going wrong with so little info.

Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5

Offline Mark Lane

  • Visitor
  • Posts: 3
  • Karma: 0
Re: Script quit working after the upgrade
« Reply #2 on: May 14, 2010, 11:02:34 AM »
tell application "QuarkXPress"
   my domain()
end tell --quarkxpress
------------------------------------------------
on domain()
   tell application "QuarkXPress"
      set xTab to {{justification:right justified, fill character:"..", position:"2.472\""}}
      tell document 1
         set horizontal measure to inches
         set vertical measure to inches
         set ThisPar to (count of every paragraph)
         set CurPage to current page
         repeat with x from 1 to count of paragraphs --of current box
            set CurSel to object reference of selection
            set TheOffset to offset of CurSel
            set PreviousTExt to object reference of text from character 1 to character TheOffset of story 1 of current box
            set TextBoxNumber to current box
            set CurrentParagraphNumber to count of paragraph in PreviousTExt
            tell selection
               try
                  set LastChar to character -2 -- of the selection (This check to see if its a price or heading)
                  --set SelText to selection
                  if LastChar is in {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "."} then
                     tell paragraph 1 -- THIS IS JUST IF ITS A HEADING
                        
                        set WordCount to (count of every word)
                        ------------------------MANUFACTURE HEADER
                        if WordCount < 4 then
                           set justification to centered
                           set font to "B Optima Bold"
                           set color to "Black"
                           set size to 12
                           set style to plain
                           --set (style of every character of paragraph i) to plain
                           ------------------GROUP DESCRIPTION
                        else if WordCount > 3 then
                           set justification to centered
                           set style to plain
                           ---set (style of every character of paragraph i) to plain
                           set font to "Optima"
                           set color to "Monthly"
                           set size to 7
                           set leading to 0
                           set left indent to "0"
                           set first indent to "0"
                           repeat with i from 1 to 1
                              if word i contains "I" then
                                 set (style of every character of paragraph i where it is "I") to off styles
                                 set (font of every character of word i where it is "I") to "times"
                                 set (style of every character of word i where it is "I") to bold ---works--
                              end if
                           end repeat
                           repeat with i from 1 to 1
                              if paragraph 1 contains "" then
                                 set (style of every character of paragraph i where it is "") to off styles
                                 set (style of every character of paragraph i where it is "") to superior
                              end if --paragraph 1 contains ""
                           end repeat
                           repeat with i from 1 to 1
                              if paragraph 1 contains "" then
                                 set (style of every character of paragraph i where it is "") to off styles
                                 set (style of every character of paragraph i where it is "") to superior
                              end if --paragraph 1 contains ""
                           end repeat
                        end if
                        if paragraph 1 contains "." then
                           set fullstop to (offset of first text where it is ".") in paragraph 1
                           set fullstart to (offset of first text) in paragraph 1
                           set font of text from character fullstart to character (fullstop + 1) of TextBoxNumber to "B Optima Bold"
                        end if --paragraph 1 contains "."
                     end tell --paragraph 1
                     --end if
                     -------------------------
                  else if LastChar is in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then
                     set K to (count of every word)
                     ------------------------
                     if K = 0 then
                        display dialog ("The Description Needs to be Selected
               or script maybe done") with icon stop
                     else
                        set WORDone to words 1 thru 1
                        set letters12 to characters 1 thru 2 of WORDone
                        set letters123 to characters 1 thru 3 of WORDone
                        set letter1 to first character of WORDone
                        set letter2 to second character of WORDone
                        set letter3 to third character of WORDone
                        set letter4 to fourth character of WORDone
                        set CharCount to (count of every character)
                        
                        tell paragraph 1
                           set tab list to xTab
                           set size to 7
                           set leading to 0
                           set justification to left justified
                           set font to "Optima"
                           set color to "Monthly"
                           set style to plain
                           set left indent to ".075"
                           set first indent to "-.075"
                           ------------------------------------------------
                           repeat with i in {1, -1, -1} -- first word, second last word, last word
                              set font of word i to "B Optima Bold"
                           end repeat
                           ------------------------------------------------
                           if word -2 is in {"Price", "Closeout", "Sale", "Introductory", "New", "Backorders"} then
                              set font of text from character -10 to character -1 to "B Optima Bold" ---sets ! to bold
                           end if
                           if word -2 is in {"Price", "Closeout", "Sale", "Introductory", "New", "Backorders"} then
                              set font of word -2 to "B Optima Bold"
                           end if
                           if word -3 is in {"Closeout", "Sale", "Introductory", "New", "Accepting"} then
                              set font of word -3 to "B Optima Bold"
                           end if
                           ------------------------------------------------
                           repeat with i from 1 to 1
                              if word i contains "I" then
                                 set (style of every character of paragraph i where it is "I") to off styles
                                 set (font of every character of word i where it is "I") to "times"
                                 set (style of every character of word i where it is "I") to bold
                              end if
                           end repeat
                           
                           repeat with i from 1 to 1
                              if paragraph 1 contains "" then
                                 set (style of every character of paragraph i where it is "") to off styles
                                 set (style of every character of paragraph i where it is "") to superior
                              end if --paragraph 1 contains ""
                           end repeat
                           
                           repeat with i from 1 to 1
                              if paragraph 1 contains "" then
                                 set (style of every character of paragraph i where it is "") to off styles
                                 set (style of every character of paragraph i where it is "") to superior
                              end if --paragraph 1 contains ""
                           end repeat
                        end tell --paragraph 1
                        set WORDone to words 1 thru 1
                        tell before word 1 of paragraph 1
                           set contents to (return & "*")
                        end tell
                     end if --last character contains 0123456789
                  end if --last character contains abc-xyz
               end try --get last character
            end tell --selection
            try
               if LastChar is in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then --this means its a price
                  set K to (count of every word)
                  --we have over 4oo brands to search, so I deleted most of them to shorten the script            
                  if WORDone starts with "A" then
                     if WORDone starts with "AB" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Arno Bernard:"
                     else if WORDone starts with "AC" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Arkansas Sharpeners:"
                     else if WORDone starts with "AZ" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Anza:"
                     end if
                  end if
                  
                  if WORDone starts with "Z" then
                     if WORDone starts with "ZL" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Zelco:"
                     else if WORDone starts with "ZIP" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Ziploc:"
                     else if WORDone starts with "Z" then
                        set PictureFolder to "Serenity:Color Images for Monthly:Z Blade:"
                     end if
                  end if
                  try
                     set PictureName to WORDone as text
                  end try
                  set thisBox to make new picture box at beginning of CurPage with properties {bounds:{1, 1, 1.5, 3.5}}
                  tell thisBox
                     try
                        set image 1 to file (PictureFolder & WORDone & ".jpg")
                        set bounds to {1, 1, 1.5, 3.5}
                        set bounds of image 1 to proportional fit
                        set bounds of image 1 to box fit
                        -- set width of bounds to 2.5
                        set bounds of image 1 to centered
                     on error
                        try
                           set image 1 to file (PictureFolder & WORDone)
                           set bounds to {1, 1, 1.5, 3.5}
                           set bounds of image 1 to proportional fit
                           set bounds of image 1 to box fit
                           -- set width of bounds to 2.5
                           set bounds of image 1 to centered
                        end try
                     end try
                  end tell --ThisBox
                  set CurrentParagraphNumber to CurrentParagraphNumber + 1
                  my SetTool("Drag")
                  set selection to null
                  set selected of thisBox to true
                  my DoMenu("Edit", "Cut")
                  my SetTool("Contents")
                  set selected of TextBoxNumber to true
                  set selection to insertion point before character 1 of CurSel
                  my DoMenu("Edit", "Paste")
                  set selection to insertion point before character 1 of CurSel
                  tell TextBoxNumber
                     tell story 1
                        try
                           set selected of paragraph (CurrentParagraphNumber + 1) to true
                        end try
                        set justification of paragraph (CurrentParagraphNumber - 1) to centered
                     end tell --story 1
                  end tell --TextBoxNumber
               end if --last character contains 0123456789
            end try -- last character
            tell TextBoxNumber
               tell story 1
                  try
                     set selected of paragraph (CurrentParagraphNumber + 1) to true
                  end try
               end tell --story 1
            end tell --Text box
         end repeat --selecting next paragraph
      end tell --document 1
   end tell --application quark3
end domain
------------------------------------------------
on SetTool(This_Tool)
   tell application "QuarkXPress"
      tell document 1
         if This_Tool is "Contents" then
            set tool mode to contents mode
         else if This_Tool is "Drag" then
            set tool mode to drag mode
         end if
      end tell
   end tell
end SetTool
------------------------------------------------
on DoMenu(This_Menu, This_SubMenu)
   tell application "QuarkXPress"
      try
         select menu item This_SubMenu of menu This_Menu
      on error errMsg number errNum
         display dialog ("An error " & errNum & " has occured" & return & return & errMsg) with icon stop
      end try
   end tell
end DoMenu
------------------------------------------------
tell application "QuarkXPress"
   activate
end tell

Offline Mark Lane

  • Visitor
  • Posts: 3
  • Karma: 0
Re: Script quit working after the upgrade
« Reply #3 on: May 14, 2010, 11:06:29 AM »
It may be hard to tell what all this script does without a quark file