23 Replies Latest reply on Dec 21, 2010 3:58 PM by leo.r

    AppleScript won't compile with CS5 apps

    leo.r Level 1

      Something is still terribly broken with CS5 AppleScript support.

      Here's the symptoms:

      I have a really long AppleScript script file, a part of Xcode project. It uses both InDesign CS4 and CS5 specific features.

      For a few months didn't have any problems.

      Suddenly, after restart it won't compile.

      Stops with warnings like "expecting a property but found identifier" and highlights the word "presets" in "print presets".

      or "export" in "PDF export presets"

      or "interaction" in "set user interaction level"

      etc.

      What the...?

      InDesign CS5 is open.

      When I change to "tell InDesign CS4" everything compiles.

      But the problem is that certain chunks of code MUST refer to InDesign CS5 because they include CS5 specific features such as JPEG export, XFL etc.

      Right now I had to comment them all. I need to release an update for my customers - it's a very popular InDesign solution - and I'm just stuck.


      I also had similar problem before with Photoshop CS5 and a long script in Script Editor. Suddenly, some words changed to «class xxxx» - even though Photoshop CS5 is open - and the only solution was to change all "tell app" blocks to CS4. But I didn't have any CS5 specific features there.


      Any idea what's going on and how to fix it?

      Thanks for any help,

      Leo

      Mac OS X 10.5.8, MacPro 2x2.66 GHz Dual-Core, 7 GB RAM

        • 1. Re: AppleScript won't compile with CS5 apps
          sstanleyau Level 4

          Reboot your Mac, start InDesign CS5 (only), then open the script again. And consider breaking your script up into smaller scripts.

          • 2. Re: AppleScript won't compile with CS5 apps
            leo.r Level 1

            Thanks a lot for the prompt reply, Steve!

            Another restart seems to have solved the problem - with both CS4 and CS5 running. I can't break this script into small ones, unfortunately. It also requires both CS4 and CS5 to compile.

            I hope to rewrite all of this in Cocoa's Scripting Bridge one day.

            • 3. Re: AppleScript won't compile with CS5 apps
              sstanleyau Level 4
              I can't break this script into small ones

               

              Is there some reason why not?

               

              It also requires both CS4 and CS5 to compile.

               

              You should check out "using terms from".

              • 4. Re: AppleScript won't compile with CS5 apps
                leo.r Level 1

                >>  I can't break this script into small ones

                > Is there some reason why not?

                This script is an Xcode .applescript file which contains numerous handles related to Interface Browser elements. It also contains an extremely complex and lengthy automated process initiated by a single click. There's also about 50 handlers related to this process. They all share tons of variables. I'm not sure how it's possible to break it into smaller scripts, but if possible at all it will be unimaginable to maintain.

                In any case, this script exists for over 4 years and always compiled with no problems, so I'd expect newer tools will make it easier to maintain it and not the other way round.


                >> It also requires both CS4 and CS5 to compile.

                > You should check out "using terms from".

                I did check it out several times, and did it again now as you mentioned it. Honestly, I still don't understand how it can be useful for me. It looks like it will require keeping both InDesign CS4 and CS5 open anyway. I found one source that suggested that a variable can be inserted instead an application name, however I get an error when trying to compile it. It's still not clear where the script would take CS5 terminology from without having it open.

                But if I'm missing something I'd appreciate any suggestions.

                Thanks again for your attention to this!

                Leo

                • 5. Re: AppleScript won't compile with CS5 apps
                  Muppet Mark-QAl63s Level 4

                  Im NOT 100% on this but your terminology should come from 'Adobe Unit Types.osax' in your Library's ScriptingAdditions folder or so me thinks… I have the 2 in there one from my CS2 install and one from my trial of CS5…

                  • 6. Re: AppleScript won't compile with CS5 apps
                    sstanleyau Level 4
                    There's also about 50 handlers related to this process. They all share tons of variables. I'm not sure how it's possible to break it into smaller scripts, but if possible at all it will be unimaginable to maintain.

                     

                    If it would be difficult to break some of it out, it's already difficult to maintain, by definition. Assuming you're not relying on globals all over the place, you should be able to bundle some handlers into a separate script and load it at run time using "load script".

                     

                    It looks like it will require keeping both InDesign CS4 and CS5 open anyway.

                    Read Adobe's documentation again. You'd have CS5 open, and address the dummy terminology-only CS4 app in using terms from.

                    1 person found this helpful
                    • 7. Re: AppleScript won't compile with CS5 apps
                      leo.r Level 1

                      Thanks so much, Shane!

                       

                      Really appreciate it!

                       

                      Kinda feel embarassed, can't wait to implement it!

                       

                      Best,

                      Leo

                      • 8. Re: AppleScript won't compile with CS5 apps
                        leo.r Level 1

                        Hi Shane,

                        I just tried to implement "using terms", but it doesn't seem to work in Xcode, unless both InDesign CS4 and CS5 are open.

                        (It does work in Script Editor).


                        Also the "publish terminology" command doesn't seem to do anything to me. At least it doesn't create anything in the location listed in the InDesign Scripting guide:

                        ~/Library/Preferences/Adobe InDesign/Version x.0/Scripting Support/x.0

                        It does take a few seconds to execute the command, so it might be creating something someplace else, I don't know. After all it works somehow in Script Editor.


                        In Xcode's .applescript files, "using terms from application InDesign CS4" doesn't work without CS4 open.

                        I thought I may need to have it open for the first time as a kick-start.

                        But even after that if I quit CS4, leave CS5 and open the project in Xcode:

                        -all "using terms from application InDesign CS4" turn into "using terms from application InDesign CS5"

                        -classes inside this block turn into
                        «class jpEr» etc.

                        -if I manually change "CS5" to "CS4" it doesn't help (unlike in Script Editor)


                        So I need to open InDesign CS4, but it doesn't help either:

                        «class
                        xxxx» doesn't turn automatically into its AppleScript name, which makes script impossible to compile so I need to change it all back manually.


                        Am I missing something? I'm reproducing the same steps I do in Script Editor, and it doesn't work in Xcode.


                        • 9. Re: AppleScript won't compile with CS5 apps
                          sstanleyau Level 4

                          The documentation is out of date -- it's now saved in ~/Library/Caches/Adobe InDesign/Version x.0/Scripting Support/x.0

                           

                          But that shouldn't matter -- it sounds like it's been created.

                           

                          In Xcode's .applescript files, "using terms from application InDesign CS4" doesn't work without CS4 open.

                           

                          You need quotes around InDesign CS4. If you still have problems, try:

                           

                          using terms from application "blah blah blah"

                          When the dialog comes up asking you to find blah blah blah, choose "InDesign CS4" (*not* "Adobe InDesign CS4").

                          • 10. Re: AppleScript won't compile with CS5 apps
                            leo.r Level 1

                            > The documentation is out of date -- it's now saved in ~/Library/Caches/Adobe
                            > InDesign/Version x.0/Scripting Support/x.0

                            > But that shouldn't matter -- it sounds like it's been created.


                            Yes that's true - thanks for the clarification.

                            > You need quotes around InDesign CS4. If you still have problems, try:

                            >> using terms from application "blah blah blah"
                            > When the dialog comes up asking you to find blah blah blah, choose "InDesign
                            > CS4" (*not* "Adobe InDesign CS4").

                            Yes, I was quoting the app in the script
                            of course. But only now I realized that in the guide they used "InDesign CS4" indeed. I used "Adobe InDesign CS4".

                            Ok, if I use "InDesign CS4" I get the dialog asking to find the app... But how do I choose "InDesign CS4"? There's only Adobe InDesign CS4 - what am I missing?

                            • 11. Re: AppleScript won't compile with CS5 apps
                              sstanleyau Level 4

                              "InDesign CS4" should also be there. If not, try putting in the full path to it in the Caches folder.

                              • 12. Re: AppleScript won't compile with CS5 apps
                                leo.r Level 1

                                Nope, doesn't work.

                                Should it be:

                                ...:Caches:Adobe InDesign:Version 6.0:en_US:Scripting Support:6.0:InDesign CS4

                                or

                                ...:Caches:Adobe InDesign:Version 7.0:en_US:Scripting Support:6.0:InDesign CS4

                                I tried both.

                                Or something else?

                                In the second path final folder, I have an app called "Adobe InDesign CS4 Dictionary" which is crossed as a Classic app and which does contain InDesign scripting dictionary.

                                If I select this, the script doesn't compile either. If I select Adobe InDesign CS4 just for testing, it still doesn't compile.


                                Thanks!

                                • 13. Re: AppleScript won't compile with CS5 apps
                                  sstanleyau Level 4

                                  I have an app called "Adobe InDesign CS4 Dictionary"

                                   

                                  That's the one. Try using the full path to it.

                                  • 14. Re: AppleScript won't compile with CS5 apps
                                    leo.r Level 1

                                    Thanks Shane, but it doesn't work.

                                     

                                    I guess it has to do something with Xcode's relationships wih AppleScript.

                                     

                                    I have a similar situation with InDesign CS3 in a regular .scpt and it works

                                    • 15. Re: AppleScript won't compile with CS5 apps
                                      sstanleyau Level 4

                                      Well I did test it here in Xcode... (3.2.4, OS X 10.6.5).

                                      • 16. Re: AppleScript won't compile with CS5 apps
                                        leo.r Level 1
                                        ok, it compiles with "Adobe InDesign CS4 Dictionary".

                                        (With all the experimenting I was expecting that «class xxxx» objects will be parsed automatically... once I changed them manually, the script compiled.)

                                        Thanks a lot for guiding me through the details (and outdated info in Adobe's guide)!



                                        But now I'm have a new concern: I want to be sure that my program won't ask users to locate "Adobe InDesign CS4 Dictionary" app.

                                        My program publishes terminology on awakeFromNib.

                                        When InDesign CS5 publishes terminology, it does create the "Adobe InDesign CS4 Dictionary" app.

                                        But InDesign CS4 does NOT create the "Adobe InDesign CS4 Dictionary" app.


                                        So what happens if user runs InDesign CS4?

                                        I deleted "Adobe InDesign CS4 Dictionary" created by CS5 and emptied trash.

                                        Left only InDesign CS4 running.

                                        Opened my program. Everything is working and it does NOT ask to locate "Adobe InDesign CS4 Dictionary".

                                        Well it's great but... why?

                                        Is it assumed that if InDesign CS4 itself is running, the script substitutes "Adobe InDesign CS4 Dictionary" with Adobe InDesign CS4 during run time?

                                        And can I be sure that if it doesn't ask to locate the app on my machine, it won't ask on others?


                                        I don't know if there are definite answers to these questions... maybe only testing will show.
                                        • 17. Re: AppleScript won't compile with CS5 apps
                                          sstanleyau Level 4

                                          I want to be sure that my program won't ask users to locate "Adobe InDesign CS4 Dictionary" app.

                                          They won't. Any references to applications in a "using terms from" statement are solely for the purpose of loading a dictionary into the script editor to make the script compile; the statements are ignored at run-time.

                                           

                                          You can also avoid the dialog asking users to locate an app even in a tell statement, as long as they are running 10.5 or 10.6, by by using application IDs, such as:

                                           

                                          tell application id "com.adobe.indesign"

                                          You then need to wrap it in a try statement.

                                          • 18. Re: AppleScript won't compile with CS5 apps
                                            leo.r Level 1

                                            Ok fantastic, makes my life mush easier now (and my app doesn't need to publish any terminology then)!

                                             

                                             

                                            And the last somewhat ambiguous piece from Adobe documentation is:

                                             

                                            set version of script preferences to x.0

                                             

                                            My understanding is that I need to insert it before "using terms" and reset it to back to the current version after.

                                            • 19. Re: AppleScript won't compile with CS5 apps
                                              sstanleyau Level 4

                                              You insert it wherever you want you code to be interpreted as being of a particular version.

                                               

                                              And make sure you set it back to the default, otherwise you will clobber other scripts.

                                              • 21. Re: AppleScript won't compile with CS5 apps
                                                leo.r Level 1

                                                Hi Shane,

                                                You know I just received an email from a customer who says that my app asks "Where is Adobe InDesign CS4
                                                Dictionary?"

                                                He gets this message just on launching the application.

                                                He's the only one to report this message so far.

                                                Should I publish terminology every time on launch? I thought I shouldn't.

                                                Am I missing something? If there's a risk of such messages, then "using terms from application..." becomes problematic...

                                                 

                                                The customer just told me he uses 10.4.11. Maybe has to do something with it?

                                                Thanks,
                                                Leo  

                                                • 22. Re: AppleScript won't compile with CS5 apps
                                                  sstanleyau Level 4

                                                  No, don't publish on each launch -- that would cause grief. It could be a problem with 10.4.11, but I don't have any way of testing that. If it is, there's not much you can do -- they would get the message about the other version of InDesign anyway.

                                                  • 23. Re: AppleScript won't compile with CS5 apps
                                                    leo.r Level 1

                                                    In the case of other InDesign version I think it's different - at least I never run into any problems.

                                                    Let's say I have "tell InDesign CS4" inside of "tell InDesign CS5" code, but there's no InDesign CS4 installed. The script will treat it as "tell InDesign CS5", turn unknown terms into  «class ****» in which case I don't care because there's no InDesign CS4 anyway. The application won't ask to find it.

                                                    It must be really a Tiger thing otherwise I'd hear much more about by now.

                                                    I might tell installer to copy terminology if it's not there.

                                                    Thanks,
                                                    Leo