How to correct number nested section identifiers?

How to correct number nested section identifiers?

49
Basic UserBasic User
49

    Dec 19, 2018#1

    Hi,

    I try to create a macro for generating nested section identifiers like:

    Input:

    id="sec1_@"
    id="sec1_@_@"
    id="sec1_@_@"
    id="sec1_@_@_@"
    id="sec1_@_@_@"
    id="sec1_@_@"
    id="sec1_@"
    id="sec1_@"
    id="sec1_@_@"
    id="sec1_@_@_@"
    id="sec1_@_@_@"
    id="sec1_@_@_@"
    id="sec1_@_@"
    id="sec1_@"
    id="sec1_@"
    id="sec1_@"

    Expected output:

    id="sec1_1"
    id="sec1_1_1"
    id="sec1_1_2"
    id="sec1_1_2_1"
    id="sec1_1_2_2"
    id="sec1_1_3"
    id="sec1_2"
    id="sec1_3"
    id="sec1_3_1"
    id="sec1_3_1_1"
    id="sec1_3_1_2"
    id="sec1_3_1_3"
    id="sec1_3_2"
    id="sec1_4"
    id="sec1_5"
    id="sec1_6"

    But after playing macro the output is:

    id="sec1_1"
    id="sec1_1_1"
    id="sec1_1_2"
    id="sec1_1_2_1"
    id="sec1_1_2_2"
    id="sec1_1_3"
    id="sec1_2"
    id="sec1_3"
    id="sec1_3_4"
    id="sec1_3_4_3"
    id="sec1_3_4_4"
    id="sec1_3_4_5"
    id="sec1_3_5"
    id="sec1_4"
    id="sec1_5"
    id="sec1_6"

    I can not solve this problem. Please help any one.

    Initial attached macro file deleted. See my next post for the extended macro file.

    6,636551
    Grand MasterGrand Master
    6,636551

      Dec 22, 2018#2

      I needed to find out first which of the macros in macro file to play. It would have been good if you would have written that in your post.

      Next I needed to find out how the macros do the section identifier numbering. I executed command Undo several times and could see how @ were replaced during macro execution. This method could not work for the numbering scheme required for this task.

      So I wrote with UltraEdit for Windows v16.30 being compatible with UEStudio v11.00 (one more thing you forget to post) a new macro with name SectionNumbering replacing all other macros with exception of macro CountUp. The first two commands, Paste and EndSelect needed to be removed from macro CountUp for this task. The macro SectionNumbering is the first macro in macro file SectionNumbering.mac in ZIP file SectionNumbering.zip. So the command Play Again can be used directly after loading the macro file. (The ZIP file was deleted later as the requirements changed and so macro code was updated, too.)
      Best regards from an UC/UE/UES for Windows user from Austria

      49
      Basic UserBasic User
      49

        Dec 24, 2018#3

        Thanks Mofi for your reply.

        Sorry for forgetting to mention some issues:
        1. The macro "01_secID1-3" should be run in my macro.
        2. Can be "_@" (section identifier numbering) 1-10 or more times.
        3. I use UEStudio v11.00
        Your macro is working very well at the above mentioned input.

        I need to follow the mentioned inputs properly.

        Please can you update your macro.

        My new input:

        id="sec1_@"
        id="sec1_@_@"
        id="sec1_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@_@_@"
        id="sec1_@_@_@_@_@"
        id="sec1_@_@_@_@_@_@"
        id="sec1_@_@_@_@_@_@_@"
        id="sec1_@_@_@_@_@_@_@_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@"
        id="sec1_@"
        id="sec1_@"
        id="sec1_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@_@_@"
        id="sec1_@_@_@_@_@"
        id="sec1_@_@_@_@_@_@"
        id="sec1_@_@_@_@_@_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@_@"
        id="sec1_@_@"
        id="sec1_@"
        id="sec1_@"
        id="sec1_@"

        I updated my macro that was initially attached in my first post. See below for extended macro file. The macro "00_secID1-6_All" should be run in my updated macro.

        Expected output:

        id="sec1_1"
        id="sec1_1_1"
        id="sec1_1_2"
        id="sec1_1_2_1"
        id="sec1_1_2_1_1"
        id="sec1_1_2_1_1_1"
        id="sec1_1_2_1_1_1_1"
        id="sec1_1_2_1_1_1_1_1"
        id="sec1_@_@_@_@_@_@_@_@_@"
        id="sec1_1_2_2"
        id="sec1_1_3"
        id="sec1_2"
        id="sec1_3"
        id="sec1_3_1"
        id="sec1_3_1_1"
        id="sec1_3_1_1_1"
        id="sec1_3_1_1_1_1"
        id="sec1_3_1_1_1_1_1"
        id="sec1_3_1_1_1_1_1_1"
        id="sec1_3_1_2"
        id="sec1_3_1_3"
        id="sec1_3_1_4"
        id="sec1_3_2"
        id="sec1_4"
        id="sec1_5"
        id="sec1_6"
        SectionID.mac (2.64 KiB)   18

        6,636551
        Grand MasterGrand Master
        6,636551

          Dec 24, 2018#4

          UltraEdit and UEStudio do not support variables in macros. The macro uses user clipboard 7 (level 1) to 9 (level 3) as variable replacement. So it is possible to rewrite the macro for up to 10 levels, but definitely not more. It would be much better to do this task with a script which supports variables and even arrays for an undermined number of levels. A script solution would be much faster and would produce less undo recordings. To use the macro SectionNumbering from within macro 00_secID1-6_All, just append at bottom PlayMacro 1 "SectionNumbering" to run it once after adding it to your macro file. I have not looked on what your macro 00_secID1-6_All really does. As I wrote in my previous post, I think they are of no need for numbering the section identifiers because of using wrong algorithm which can't work. My macro file with slightly modified CountUp and with main macro SectionNumbering replace all in your macro file.
          Best regards from an UC/UE/UES for Windows user from Austria

          49
          Basic UserBasic User
          49

            Dec 25, 2018#5

            Thanks again Mofi for your important advice. My macro is working properly, but very slow. I am understanding your advice. But I cannot update the macro as of your information. I know, a script would be a better solution. But please can you provide a macro which supports up to 10 levels.

            6,636551
            Grand MasterGrand Master
            6,636551

              Dec 27, 2018#6

              The attached ZIP file SectionNumbering.zip contains the macro file with updated macro SectionNumbering which supports now up to 10 levels.
              SectionNumbering.zip (545 Bytes)   22
              The ZIP file contains macro file SectionNumbering.mac created with UE v16.30.
              Best regards from an UC/UE/UES for Windows user from Austria

              49
              Basic UserBasic User
              49

                Dec 28, 2018#7

                Dear Mofi,
                Thank you for your efforts. 👌