8 Replies Latest reply on Feb 7, 2015 9:18 AM by UQg

    End an external object in extendscript

    i.akbari

      Hi

      In Extendscript I create an ExternalObject object. It is an DLL in Visual C++. I call a function in it and obtain the result then I unload it.

      var basiceo = new ExternalObject("lib:" + "d:/file.dll");
      alert(basiceo.getAverage(10, 20, 0));
      basiceo
      .unload();

      This is just like the sample in Extendscript Toolkit SDK.

      Now if I make change in the DLL code, I can not build(compile) it any more. It gives me this error:

      error LNK1104: cannot open file 'd:/file.dll'

      It seems that the file has not been closed. If I close the Extendscript, I can build(compile) the code without error.

      How can I finish the external object in extendscript correctly?

      Thanks

        • 1. Re: End an external object in extendscript
          Laubender Adobe Community Professional & MVP

          Did you try with the close() method of the File Class?

           

          CS3 JS: File

           

          Uwe

          • 2. Re: End an external object in extendscript
            i.akbari Level 1

            In what way? Could you tell me an example?

             

            close("d:/file.dll");

            Error: close is not a function

             

            File.close("d:/file.dll");

            Error: File.close is not a function

             

            basiceo.close();

            Error: basiceo.close is not a function


            • 3. Re: End an external object in extendscript
              Laubender Adobe Community Professional & MVP

              I'm on Mac OSX, so I'm not sure about the file path syntax here.
              Also, if at all it is possible to open a dll kind of file by ExtendScript.

               

              But you could try the following:

               

              //I'm not sure about the file path here,
              //because I'm on Mac OSX.
              //Basically it should work this way:
              
              var myFile = new File("d:/file.dll");
              
              if(myFile.exists){
              
                  myFile.open("r"); //Read only
                  myFile.close();
              
                  };
              

               

               

              Uwe

              • 4. Re: End an external object in extendscript
                i.akbari Level 1

                Thank you for your response but My "basiceo" is an externalobject object not a File! So it does not have close method.

                I can not even imagine this code works. I think they are completely two different things.


                var basiceo = new ExternalObject("lib:" + "d:/file.dll");

                and

                var myFile = new File("d:/file.dll");

                 



                • 5. Re: End an external object in extendscript
                  UQg Level 4

                  From the Scripting Guide, page 200,

                  mylib = new ExternalObject ("lib:" + samplelib); // load the library
                  alert(mylib.version) ;
                  // access functions directly from ExternalObject instance
                  var a = mylib.method_abc(1,2.0,true, "this is data") ;
                  alert(a) ;
                  mylib.unload() ;

                   

                  So externalObjects have an "unload" method.

                  Worth trying.

                  They might have other useful methods, you can put a breakpoint at the creation point of basiceo at scout the ESTK data browser.

                   

                  Xavier

                  • 6. Re: End an external object in extendscript
                    UQg Level 4

                    Hum, i wrote that too fast: still from the Scripting Guide, instances of ExternalObject have just one method: terminate();

                     

                    So the 'unload' method in the above post was probably assumed to be one defined int he library itself.

                     

                    Xavier.

                     

                    terminate()
                    ExternalObject_obj.terminate ()
                    Explicitly shuts down the ExternalObject dynamic library wrapped by this instance.
                    It can be helpful to force a shutdown of the external library if termination of external libraries during
                    the shutdown of the hosting application does not occur in the correct order.
                    Returns undefined.

                    • 7. Re: End an external object in extendscript
                      i.akbari Level 1

                      UQg

                      the "ExternalObject_obj.terminate ()" returns "undefined". It means that there is something wrong. I had tried it before.

                      I also tried these things however they did not work.

                       

                      ExternalObject.unwatch();

                      ExternalObject.ESTerminate();

                      • 8. Re: End an external object in extendscript
                        UQg Level 4

                        the "ExternalObject_obj.terminate ()" returns "undefined". It means that there is something wrong.

                         

                        basiceo.terminate() : Explicitly shuts down the ExternalObject dynamic library wrapped by this instance (basiceo).... Returns undefined.


                        So, that it returns undefined is completely normal, not wrong. But why it does not shut down the library i can't tell...

                         

                        Xavier.