13 Replies Latest reply on Oct 16, 2011 10:22 AM by Muppet Mark

    Reading Binary

    Muppet Mark Level 5

      Im having issues trying to use the ESTK and read a file object that is 'BINARY' is anybody else having this issue?

       

      Do be warned… that when ever I try this the Toolkit locks out and I can't save out… only force quit…

       

      So save and close any docs that are important to you…

       

      The Toolkit will run only the 1 time… then lock down. Is this a known issue or just my install?

        • 1. Re: Reading Binary
          Dirk Becker Level 4

          ESTK is a text editor, so why would you want to read a binary?

          In case you mean to read it from within a script using a File object, did you accordingly set the encoding to "binary"? Otherwise the File object attempts to guess UTF encoding, line endings and so forth from the first few 1000 bytes.

           

          Dirk

          • 2. Re: Reading Binary
            Muppet Mark Level 5

            Dirk, yes and yes… Im only trying to parse some strings from some PS files… But even this…

             

            var f = File( '~/Desktop/P8140055.tif' );
              
            f.open( 'r' );
            
            f.encoding = 'BINARY';
            
            var binData = f.read();
            
            $.writeln( binData.length );
              
            f.close();
            

             

            Reads then locks me out… Won't run again, won't c&p and when forced quit forgets my recent files…

            • 3. Re: Reading Binary
              Dirk Becker Level 4

              I usually set the encoding before I even call open, because (as mentioned in the Javascript tools guide) open already tries some magic.

              Btw, you should check the result of open(), and only proceed if it is true meaning success.

               

              read() also is supposed to set the "error" property, another thing to check if only you got that far.

               

              To nail down the blocked situation, have a look at the OSX activity monitor and there the "Sample Process" panel for your process. The scripting engine of InDesign unfortunately has only few meaning symbols but in your case (if you're really targeting ESTK's own JS engine) or if your blocking is within the OS you might see a to some degree meaningful stack.

               

              Dirk

              • 4. Re: Reading Binary
                Muppet Mark Level 5

                Dirk, I was thinking that f.open( 'r' ); was just allowing me access to the file… However that said I have tried putting the encoding before, after and out altogether letting it auto detect… In activity monitor the toolkit goes top of the process stack after about 10 seconds turns red and application not responding 30 seconds later comes back… But then the toolkit is non responsive until I quit and restart…

                • 5. Re: Reading Binary
                  John Hawkinson Level 5

                  Wow. You guys are impressively talking past each other.

                   

                  When Dirk says:

                   

                  ESTK is a text editor, so why would you want to read a binary?

                  The scripting engine of InDesign unfortunately has only few meaning symbols but in your case (if you're really targeting ESTK's own JS engine) or if your blocking is within the OS you might see a to some degree meaningful stack.

                  He's either mislead or kind of kidding. Mark is not targetting the ESTK. I think he's targetting InDesign. Mark, do be explicit: you have the ESTK target set, next to the chainlink, to InDesign, yes?

                  estktarget.png

                   

                  Also, Mark, please tell us what version of the ESTK and version of InDesign (or whatever target) you are using!

                   

                  … Im only trying to parse some strings from some PS files

                  This doens't make any sense. Why is your sample opening a TIFF? That's a completely different operation with no similar file structure to postscript files. I suppose there are some metadata strings in TIFF files, but do you really want to go there in ExtendScript? [oh hey! That's a cute icon for (!)]

                   

                  Mark, when Dirk says:

                  To nail down the blocked situation, have a look at the OSX activity monitor and there the "Sample Process" panel for your process. The scripting engine of InDesign unfortunately has only few meaning symbols but in your case (if you're really targeting ESTK's own JS engine) or if your blocking is within the OS you might see a to some degree meaningful stack.

                  He means you should open Activity Monitor, choose the high cpu process (InDesign?), and click Sample Process, and stare at the report (or upload it to http://pastebin.com/ and post a link here. Don't upload it here).

                  In activity monitor the toolkit goes top of the process stack after about 10 seconds turns red and application not responding 30 seconds later comes back… But then the toolkit is non responsive until I quit and restart…

                  I tried a few versions and I didn't see this problem, at least not consistently (I might have misread it the first time, oops). Perhaps it has something to do with your file. You should make the file (P8140055.tif) available, I think.

                  • 6. Re: Reading Binary
                    Muppet Mark Level 5

                    John, thanks I will try be a little clearer… My mac is running 10.5.8 and I've got CS5 not the latest 5.5 my Toolkit is 4.1.25 What Im trying to do is read a variety of Photoshop files… *.psd, *.jpg & *.tif mostly. Working with this stuff is new to me… Trying to teach myself something but getting nowhere (well that won't be a first). I don't think the problem relates to the image in question I get this with any file I try. I have run the same script as above with the encoding put before the read and get the same result which ever app engine I target… The script was actually going to be for Bridge but I don't think thats going to change anything. While its off spinning this is what I can see… If nobody else is seeing this kind of problem or an error in my syntax then I will have to look at some system maintenance…

                     

                    Picture 2.png

                     

                    Picture 3.png

                    • 7. Re: Reading Binary
                      John Hawkinson Level 5

                      Ahem. As Dirk and I both said now:

                       

                      open Activity Monitor, choose the high cpu process (InDesign?), and click Sample Process,

                       

                      You appear to have opened Activity Monitor but not clicked the button. Please give it a shot!


                       

                      Also:

                      What Im trying to do is read a variety of Photoshop files… *.psd, *.jpg & *.tif mostly.

                      Just what do you intend to do with the contents of these files? There is probably a better way to accomplish whatever it is you're trying to do...

                       

                       

                      Are your screenshots both from targetting Bridge? Or one in Bridge and one in Photoshop? Because it looks like different issues.

                      • 8. Re: Reading Binary
                        Dirk Becker Level 4

                        John,

                         

                        thanks for your clarifications. As I had seen Mark working across different target applications (bridge etc.) I thought he was aware of the difference when he specifically mentioned ESTK. Besides I happened to just recently write a few scripts that actually target ESTK, so I did not think it was too far off.

                         

                        Btw, it could indeed give us some progress if the script was actually tried targeting ESTK itself - that would eliminate any bridgetalk communications for the debug session between ESTK and InDesign. On the other hand I fear that we're facing a machine specific problem.

                         

                        Dirk

                        • 9. Re: Reading Binary
                          Harbs. Level 6

                          Did you try restarting your machine?

                           

                          Harbs

                          • 10. Re: Reading Binary
                            Muppet Mark Level 5

                            Harbs, if you include throwing the mac further than the power cable reaches then yes… I probably could do with a newer one with some more grunt… Just tried again… Will post the log in a minute…

                            • 11. Re: Reading Binary
                              Muppet Mark Level 5

                              John, I hope I catured this at the right time… This was with ID as target… Thats the only part of this I can read…?

                               

                              http://pastebin.com/yPVJkpJC

                              • 12. Re: Reading Binary
                                Dirk Becker Level 4

                                Reading crash logs, and the similar samplings like here, with scripting involved is a bit imprecise because Adobe omits quite a few debugger symbols in the scripting engine.

                                 

                                Line 17 looks like the XML based communication between ESTK debugger and the ExtendScript engine.

                                Line 18 would then be the actual command - looking for some watchpoints.

                                 

                                Please try to zap the watchpoints of the JSX debugger, if you have any. Also close all related panels within ESTK, that would especially be the "Data Browser". In a very large scripting project I experience semi freezes (that recover after while, unlike yours) when the data browser just builds a list of all the globals.

                                 

                                What happens if you run the script enclosed in a function? That would hide the global scope from the data browser ...

                                 

                                Please also retry to run the same script targeting ESTK rather than InDesign.

                                 

                                Dirk

                                • 13. Re: Reading Binary
                                  Muppet Mark Level 5

                                  Thank you both don't worry about it… I've plenty of other subject matter I can move on to instead… It was probably over ambitious of me anyhows… It can go to the back of the 'to do' list until next time around… I did discover a bad file count so I fixed that…