13 Replies Latest reply on Jul 5, 2016 8:52 AM by Loic.Aigon

    scripting problem indesign 2015.5

    gert verrept Level 2

      General question, have changes been made the way JavaScript are handled in the latest update of Indesign? Some of our scripts make CC2015.5 crash. They worked fine in the previous version, but on several PC's they make Indesign crash (win 7 64b). Sometimes the script passes, sometimes not.Some of these scripts refer to an external text file, which stores some variables, others just show a list of possibilities to choose from. We often use the script labels in the scripts, so maybe the problems are in that area.

      Someone else with scripting issues of that kind? We reverted to the previous version (2015.4) and all runs well again.

        • 1. Re: scripting problem indesign 2015.5
          Laubender Adobe Community Professional & MVP

          Hi Gert,

          I think you refer to InDesign CC 2015.4 v11.4.0.90 and reverted to InDesign CC 2015.3 …

           

          Did not test .4 vs .3 extensively, so I could not tell what's going on.

          If something has changed on the property or value range side, errors should be thrown and no crashes should occur.

          So we have a bug situation here, I think. Maybe a memory leak? Can you check this?

           

          Note: I'm on Mac OSX 10.10.3 and not on Windows.

           

          Regards,
          Uwe

          • 2. Re: scripting problem indesign 2015.5
            gert verrept Level 2

            I'll try by trashing the prefs on one PC (I hate this, it always means a day's work to get all OK again), and see what happens afterwards. Could network be an issue too? All the files are stored on a server, as are the scripts (we made a shortcut to the folder of scripts so we only have to adapt the script once and all the others have the right version too.

            • 3. Re: scripting problem indesign 2015.5
              gert verrept Level 2

              Dropbox - ALL_REF_DATE.jsx

               

              This is the script which each time it's used makes CC2015.4 crash. The external .txt file points to a folder on the server.

              The scripts are run from the server, but also locally the script makes Indesign crash.

              • 4. Re: scripting problem indesign 2015.5
                Loic.Aigon Adobe Community Professional

                Did you include a log mechanism to see if the crashing point is on a specific line of code ? There coudl be dozens of issues like inadequate value, illegal operation, memory leak…

                 

                You could do something like:

                function log(msg) {
                  var f = new File ( Folder.desktop+"/log.txt" );
                  f.open('a');
                  f.writeln ( "["+$.line+"]"+msg );
                  f.close();
                }
                
                
                
                
                log("hey");
                

                That way you can follow the process of your script.

                And see the latest report sent.

                Then you can investigate on what's wrong.

                 

                 

                FWIW

                 

                Loic

                Ozalto | Productivity Oriented - Loïc Aigon

                • 5. Re: scripting problem indesign 2015.5
                  gert verrept Level 2

                  Sorry, but can someone change the header of my question? As Uwe said, it's 2015.4 not .5. My mistake, but I cannot change it anymore.

                  @Loic: Strange, but at home, using the same scripts, no problems found, all runs well. Once back to work, I'll check it with the log enabled.

                  • 6. Re: scripting problem indesign 2015.5
                    Kasyan Servetsky Level 5

                    I tried to run your script on my machine in InDesign 2015.4 (11.4.0.90 x32) on Windows 10 and it didn't crash.
                    It reached line 600 and didn't find the labeled text frame (internal_ref) so it threw an error: "This document has not the right scriptlabels.". Before that I created the B-front page master page and labeled items on it. So I thought the problem was there and tried another approach, like so:

                    function FindLabels(there, label) {
                        var array = [];
                        var pageItems = there.allPageItems;
                        for (var i = 0; i < pageItems.length; i++) {
                            if (pageItems[i].label == label) array.push(pageItems[i]);
                        }
                        return array;
                    }
                    
                    function lees_dubbel_nummers(){
                    
                        var arr = FindLabels(app.activeDocument.masterSpreads.item("B-front page"), "internal_ref");
                    
                        if (arr.length > 0) {
                            intern_nummer = arr[0].contents;
                        }
                    
                        arr = FindLabels(app.activeDocument.masterSpreads.item("B-front page"), "account_number");
                    
                        if (arr.length > 0) {
                            intern_nummer = arr[0].contents;
                        }
                    
                        arr = FindLabels(app.activeDocument.masterSpreads.item("B-front page"), "kamer_left");
                    
                        if (arr.length > 0) {
                            intern_nummer = arr[0].contents;
                        }
                        
                        arr = FindLabels(app.activeDocument.masterSpreads.item("B-front page"), "senaat_left");
                    
                        if (arr.length > 0) {
                            intern_nummer = arr[0].contents;
                        }
                    
                    

                    This time it stopped somewhere in the function making the dialog box because of the invalid parameters. (Sure, I have no idea about which data should be in the frames).

                     

                    Regards,
                    Kasyan

                    • 7. Re: scripting problem indesign 2015.5
                      gert verrept Level 2

                      @Kasyan: the script is used to enter the various document numbers for this file. I tried the log file from Loic, but I only get an empty txt file. As I said, at home no problem, at the office 11 pc (which all have the same config, win 7 64b) crash randomly.

                      • 8. Re: scripting problem indesign 2015.5
                        Kasyan Servetsky Level 5

                        Sorry, I didn't read your post #5 carefully.

                        Indeed working with files located on network may cause problems. At my work we constantly experience issues like crashing InDesign and Photoshop.

                         

                        1. I'd recommend you to run the script from ESTK step-by-step till you reach the line which crashes InDesign. Though it may take time since it crashes randomly.

                         

                        2. Also you may add lines like so:

                        function datum_check() {
                             $.writeln("Entering 'function datum_check'");
                             
                        // Then before 'return'
                            $.writeln("Going to exit 'function datum_check'");
                            return datum_check;
                        }
                        

                        This may help you to narrow the search zone: if the crash happens in this function, you'll see the name of problematic function in the last message in console.

                         

                        3. You may also add try-catch blocks like so:

                        function foo() {
                            try {
                                // do something here
                            }
                            catch(err) {
                                $.writeln(err.message + ", line: " + err.line);
                            }
                        }
                        

                        It will write an error message and the line# where it happens.

                         

                        4. Also I recommend you to use these settings for debugging in ESTK (I always use them):

                        7-4-2016 6-18-14 PM.png

                        In this way I can see which lines were executed (and how many times) and which not, and quickly find the exact place where something went wrong.

                        Though if InDesign crashes, options 3 and 4 may not work.

                        • 9. Re: scripting problem indesign 2015.5
                          Loic.Aigon Adobe Community Professional

                          I tried the log file from Loic, but I only get an empty txt file.

                          It's weird I use this kind of logging in desktop and server versions without any issues.

                          Unless it's a right management issue but then even the file should not be created.
                          Feel free to send me more details in private (meaning for the logging issue).

                          • 10. Re: scripting problem indesign 2015.5
                            gert verrept Level 2

                            @all: We solved the problem by deleting all the previous versions of Indesign (prefs and all the rest which is left behind...), cleaned the registry (windows 7 64b), uninstalled the CC2015.4 version completely and reinstalled the latest version (via the desktop app).

                            Another solution was: creating a new user profile and logging on with that account (we tried this first, but creating 11 profiles is more work then deleting Indeisgn).

                            @Loic: is it possible that the log files stays empty because Indesign just crashes (maybe is wasn't executing anything). The one thing I got in the file was [304] "hey".

                            • 11. Re: scripting problem indesign 2015.5
                              Loic.Aigon Adobe Community Professional

                              The one thing I got in the file was [304] "hey".

                              Oh then it looks like it worked perfectly to me. The idea was to call this function regularly. So eventually when InDesign crashes you can note the last call start digging from there. I used that all the time.

                               

                              So it could have been

                              //Some code of yours
                              log("Wow we just started!");
                              //Another code of yours
                              log("Well until then, everything is fine");
                              //Some code that makes InDesign crash
                              log("You shouldn't see me in the log file as InDesign just crashed. \
                              So problem is obviously somewhere between here and the last log call…");
                              

                               

                              FWIW

                               

                              Loic

                              • 12. Re: scripting problem indesign 2015.5
                                gert verrept Level 2

                                Oh ok, I've put it only once in the script (just before the call for the date), and it's at that moment that CC crashed. As I said in the previous reply, it seems more a "indesign defaults" problem than something else. Maybe someone else has better solution then to delete all "old" versions, but it worked.

                                Thanks for the "log" function.

                                 

                                Gert

                                • 13. Re: scripting problem indesign 2015.5
                                  Loic.Aigon Adobe Community Professional

                                  You can still add it so if it later crashes again, you will know