Problem using activeDocumentIdx

Problem using activeDocumentIdx

3
NewbieNewbie
3

    Apr 27, 2010#1

    I am having a problem using activeDocumentIdx in a script. I have uploaded the files that illustrate the problem (already deleted), reduced to the minimum I could create that shows it. My sample script loops opening two files, moving the cursor to the beginning of one file, then closing the files; then repeat on another pair of files. The script foo1.js exhibits the problem; the script foo.js has the opening and closing of one of the files commented out and it goes through the loop just fine. The interesting thing is that the foo1 script succeeds the first time through the loop and fails the second iteration.

    I am running version 16.00.0.1038 under W7.

    Any insights?
    Thanks!

      Apr 27, 2010#2

      I see the style is to put the code inline where it is visible (sorry - I'm new here).

      The failing script looks like this:

      Code: Select all

      UltraEdit.outputWindow.showWindow(true);
      UltraEdit.outputWindow.showOutput=true;
      
      var filenum = 1;
      var maxFiles = 5;  //<<<-- update with num of files
      while (filenum<=maxFiles){
      	UltraEdit.open("c:\\scratch\\test"+filenum+".txt");
      	docIndex = UltraEdit.activeDocumentIdx;
      	UltraEdit.newFile();
      	UltraEdit.saveAs("c:\\scratch\\testW"+filenum+".txt");
      	docWIndex = UltraEdit.activeDocumentIdx;
      
      	//go to start of data
      	UltraEdit.document[docIndex].gotoLine(1,1);
      
      	UltraEdit.closeFile("c:\\scratch\\test"+filenum+".txt",2);
      	UltraEdit.closeFile("c:\\scratch\\testW"+filenum+".txt",1);
      	filenum++;
      }
      
      This version works:

      Code: Select all

      UltraEdit.outputWindow.showWindow(true);
      UltraEdit.outputWindow.showOutput=true;
      
      var filenum = 1;
      var maxFiles = 5;  //<<<-- update with num of files
      while (filenum<=maxFiles){
      	UltraEdit.open("c:\\scratch\\test"+filenum+".txt");
      	docIndex = UltraEdit.activeDocumentIdx;
      //	UltraEdit.newFile();
      //	UltraEdit.saveAs("c:\\scratch\\testW"+filenum+".txt");
      //	docWIndex = UltraEdit.activeDocumentIdx;
      
      	//go to start of data
      	UltraEdit.document[docIndex].gotoLine(1,1);
      
      	UltraEdit.closeFile("c:\\scratch\\test"+filenum+".txt",2);
      //	UltraEdit.closeFile("c:\\scratch\\testW"+filenum+".txt",1);
      	filenum++;
      }
      

      262
      MasterMaster
      262

        Apr 28, 2010#3

        There is an error in UE 16.00.0.1038 with UltraEdit.saveAs() which somehow "breaks" the further operation in the active file that was saved. UE support has confirmed this error when I reported it a week ago. This is my testcase which fails:

        Code: Select all

        UltraEdit.newFile();
        UltraEdit.activeDocument.write("before save\r\n");
        UltraEdit.saveAs("\\temp\\temp.txt");
        UltraEdit.activeDocument.write("after save\r\n");
        Only the first write is performed.

        Hotfix UE 16.00.0.1040 was released yesterday but the error is still there. So I guess we should be patient.

        3
        NewbieNewbie
        3

          Apr 29, 2010#4

          UE support also confirmed that my example is running into this bug. They are working on it. Thanks for your reply.

          262
          MasterMaster
          262

            May 07, 2010#5

            This problems seems to be fixed in UltraEdit v16.10.