Is it possible to renumbering the footnotes?

Is it possible to renumbering the footnotes?

7
NewbieNewbie
7

    Aug 07, 2007#1

    Greeting form Seoul!

    I have a huge text file. And I have to change the whole text file.
    please help me..
    Original text has footnotes, and thoses are ascending alphabetical order by chapter, but I would like to change the footnote to alphabetical order by verse.
    In ohter words, when the verse changes, then renumbering the footnote form a,b,c should be applied.

    Is it possible?
    It could be very helpful if it could possible.


    --- orginal text ----
    \v 1 Genealogie de Jesus-Christ, fils de \x a \xo David, fils d’Abraham. \x b \xo Abraham engendra Isaac ;

    \v 2 \x c \xo Isaac engendra Jacob ; \x d \xo Jacob engendra Juda et ses freres ; \x e \xo Juda engendra de Thamar Phares et Zara

    ---- wanted result---------
    \v 1 Genealogie de Jesus-Christ, fils de \x a \xo David, fils d’Abraham. \x b \xo Abraham engendra Isaac ;

    \v 2 \x a \xo Isaac engendra Jacob ; \x b \xo Jacob engendra Juda et ses freres ; \x c \xo Juda engendra de Thamar Phares et Zara

    6,687587
    Grand MasterGrand Master
    6,687587

      Aug 07, 2007#2

      With a script this could be done very easily. With a macro it would be very hard to do this because incrementing the letter is very hard to code with a macro, but very easy with a script.

      Have you read the sticky forum topic Help for new forum members - read this before post anywhere!

      There you can read that most important for us to help other users is the version of UltraEdit. Scripts are only supported with UltraEdit v13.00 or later. As long as you don't tell use the version of UE you use, nobody would spent time to write the script for that job.
      Best regards from an UC/UE/UES for Windows user from Austria

      7
      NewbieNewbie
      7

        Aug 08, 2007#3

        My college has Ultraedit 13. and he ask for the job.

        In stead of him, I post the question.

        Making script is very hard for me.

        Thanks in advance.

        6,687587
        Grand MasterGrand Master
        6,687587

          Aug 09, 2007#4

          I'm a beginner for scripts, but I hope following script works for you. It works for your example. Tested with UltraEdit v13.10a+1. You need at least v13.10.

          Code: Select all

          /* Script to change
          
          \v 1 Genealogie de Jesus-Christ, fils de \x a \xo David, fils d’Abraham. \x b \xo Abraham engendra Isaac ; 
          
          \v 2 \x c \xo Isaac engendra Jacob ; \x d \xo Jacob engendra Juda et ses freres ; \x e \xo Juda engendra de Thamar Phares et Zara 
          
          to
          
          \v 1 Genealogie de Jesus-Christ, fils de \x a \xo David, fils d’Abraham. \x b \xo Abraham engendra Isaac ; 
          
          \v 2 \x a \xo Isaac engendra Jacob ; \x b \xo Jacob engendra Juda et ses freres ; \x c \xo Juda engendra de Thamar Phares et Zara
          
          
          This script requires UltraEdit v13.10 or UEStudio v6.30 or any later version. */
          
          if ( UltraEdit.messageBox )
          {
          
           var actnumber = 0;  // Index number in the following array of footnote numbers which can be increased at any time with more alphabetical numbers.
           var footnotes = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
           var tempindex = 0;  // Document index number of temporary file.
          
           // Set working environment required for this job.
           UltraEdit.insertMode();
           UltraEdit.columnModeOff();
           UltraEdit.activeDocument.hexOff();
           UltraEdit.ueReOn();
           UltraEdit.selectClipboard(9);
           
           // Make sure last line of file has a line termination.
           UltraEdit.activeDocument.bottom();
           if (UltraEdit.activeDocument.isColNumGt(1)) UltraEdit.activeDocument.insertLine();
           UltraEdit.activeDocument.top();
           actnumber = getActiveDocumentIndex();
           
           // Create a new file where the footnotes are renumbered.
           UltraEdit.newFile();
           tempindex = UltraEdit.document.length - 1;
           // Switch back to source file.
           UltraEdit.document[actnumber].setActive();
           
           // Run the following loop from top to bottom until no footnote line is found anymore.
           while(true)
           {
            UltraEdit.activeDocument.findReplace.matchWord=false;
            UltraEdit.activeDocument.findReplace.searchDown=true;
            UltraEdit.activeDocument.findReplace.matchCase=true;
            UltraEdit.activeDocument.findReplace.regExp=true;
            UltraEdit.activeDocument.findReplace.find("\\v [0-9]+*$");
            if (UltraEdit.activeDocument.isNotFound()) break;
           
            // Copy found footnote line to temporary file.
            UltraEdit.activeDocument.copy();
            UltraEdit.document[tempindex].paste();
            UltraEdit.document[tempindex].top();
            UltraEdit.document[tempindex].findReplace.matchWord=false;
            UltraEdit.document[tempindex].findReplace.searchDown=true;
            UltraEdit.document[tempindex].findReplace.matchCase=true;
            UltraEdit.document[tempindex].findReplace.regExp=true;
            UltraEdit.document[tempindex].findReplace.replaceAll=false;
            UltraEdit.document[tempindex].findReplace.replaceInAllOpen=false;
           
            // Renumber with replaces the footnote numbers in the temporary file.
            actnumber = 0;
            do
            {
             UltraEdit.document[tempindex].findReplace.replace("\\x [a-z]+ \\xo","\\x "+footnotes[actnumber]+" \\xo");
             if (UltraEdit.document[tempindex].isNotFound()) break;
             actnumber++;
            }
            while(actnumber < footnotes.length);
           
            // When there are more footnotes than numbers specified in the array display an error message.
            if (actnumber == footnotes.length)
            {
             UltraEdit.document[tempindex].findReplace.find("\\x [a-z]+ \\xo");
             if (UltraEdit.document[tempindex].isFound())
             {
              UltraEdit.messageBox("The quantity of footnote numbers is not enough!\nModify the footnotes array and run the script again.\n\nThe script continues after pressing OK.","Not enough footnote numbers");
             }
            }
           
            // Copy the renumbered footnote line back to source file over still existing selection.
            UltraEdit.document[tempindex].selectLine();
            UltraEdit.document[tempindex].cut();
            UltraEdit.activeDocument.paste();
           }
           
           // Close the temporary file without saving, clear user clipboard 9 and switch back to Windows clipboard.
           UltraEdit.activeDocument.top();
           UltraEdit.closeFile(UltraEdit.document[tempindex].path,2);
           UltraEdit.clearClipboard();
           UltraEdit.selectClipboard(0);
          }
          
          /* Find the tab index of the active document.
             Copied from forum topic: Get Active Document's Index
             http://forums.ultraedit.com/viewtopic.php?f=52&t=4571 */
          function getActiveDocumentIndex() {
             var tabindex = -1; /* start value */
          
             for (i = 0; i < UltraEdit.document.length; i++)
             {
                if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
                   tabindex = i;
                   break;
                }
             }
             return tabindex;
          }
          Best regards from an UC/UE/UES for Windows user from Austria

          7
          NewbieNewbie
          7

            Sep 04, 2007#5

            Sorry for the late response. due to transfering the other position.
            I couldn't check up the files for a moments.

            It works well(Great ^^). Thank you very much your help.