Another Counter/Increment Question

Another Counter/Increment Question

1
NewbieNewbie
1

    Dec 21, 2006#1

    Hello - I hated to post this, especially with all the other great posts out there, but I have been working on this for way too long without getting the end result. I have been using Mofi's "CountUp" macro as a template.

    Here is sample Data:

    11252544231User1
    1210100600900008053400000234800034299
    1210100612600000045600000000000000000
    1210100613300000024300000000000000000
    13
    1620
    11765365011User2
    1210100610200000975000000000000000000
    1210100610000002016100000000000000000
    1210100606000000100800000000000000000
    13
    1620
    11317778011User3
    1210100602100001638300000049200033299
    1210100606000000016400000000000000000
    1210100612600000038700000000000000000
    1210100613300000024300000000000000000
    13
    1620
    11740292174User4
    1210110600500000049000000002800017300
    17091306 131200 131300 10000
    13
    1620
    11500745174User5
    1210110600500000049000000002800017300
    17091306 206600 206700 10000
    13
    1620

    I am trying to insert a preceding column that will read the "11" in the first two columns and assign a incremental 4 digit number in that column until the macro reads the "11" again, at which time the number is increased by one so the resulting data would look like:

    000111252544231User1
    00011210100600900008053400000234800034299
    00011210100612600000045600000000000000000
    00011210100613300000024300000000000000000
    000113
    00011620
    000211765365011User2
    00021210100610200000975000000000000000000
    00021210100610000002016100000000000000000
    00021210100606000000100800000000000000000
    000213
    00021620
    000311317778011User3
    00031210100602100001638300000049200033299
    00031210100606000000016400000000000000000
    00031210100612600000038700000000000000000
    00031210100613300000024300000000000000000
    000313
    00031620

    I am sure Mofi's macro will work, but I can't get it to. Any suggestions?
    Thanks in advance.

    6,684586
    Grand MasterGrand Master
    6,684586

      Dec 21, 2006#2

      Here is the macro which needs the macro property Continue if a Find with Replace not found checked for this macro. It was quite simple for me, except that after inserting the incremented number at start of every selected line the cursor is not anymore in the last line selected before inserting and it depends on the number of lines and the line lengths where the cursor is after inserting.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Bottom
      IfColNumGt 1
      InsertLine
      EndIf
      Top
      "0000"
      Clipboard 9
      StartSelect
      SelectToTop
      Cut
      Loop
      Find RegExp "%11"
      IfNotFound
      ExitLoop
      EndIf
      Key HOME
      PlayMacro 1 "CountUp"
      Key HOME
      Key DOWN ARROW
      StartSelect
      Find RegExp Select "%11"
      IfSel
      Key UP ARROW
      Else
      SelectToBottom
      EndIf
      Find RegExp "%^(?^)"
      Replace All SelectText "^c^1"
      EndSelect
      Key HOME
      IfEof
      ExitLoop
      Else
      Find RegExp Up "%11"
      IfFound
      Key HOME
      EndIf
      EndIf
      EndLoop
      ClearClipboard
      Clipboard 0

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria