Nested loop bug

Nested loop bug

3
NewbieNewbie
3

    Apr 19, 2005#1

    I found what appears to be a bug with nested loops (not even sure UE supports nested loops, but it doesn't say anywhere that it doesn't). My macro takes a line and reformats it. However, when the outer EndLoop (last line) is hit, the macro repeats from the previous EndLoop 11 lines back, not from the first Loop at beginning. Here's my macro:

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    UnixReOff
    Loop 
    Key HOME
    Key Ctrl+RIGHT ARROW
    Key Ctrl+RIGHT ARROW
    IfCharIs "Datalist: "
    Key END
    Key Ctrl+LEFT ARROW
    Key Ctrl+LEFT ARROW
    Key Ctrl+LEFT ARROW
    DeleteToEndofLine
    Key HOME
    Key Ctrl+RIGHT ARROW
    DeleteToStartofLine
    StartSelect
    Key Ctrl+RIGHT ARROW
    Cut 
    Key Ctrl+RIGHT ARROW
    Key Ctrl+RIGHT ARROW
    Loop 8
    IfCharIs ","
    ExitLoop
    Else
    Key RIGHT ARROW
    EndIf
    EndLoop
    Loop 8
    IfColNumGt 18
    ExitLoop
    Else
    " "
    EndIf
    EndLoop
    Key RIGHT ARROW
    Key RIGHT ARROW
    Paste 
    StartSelect
    Key END
    Cut 
    Key HOME
    Paste 
    Key DOWN ARROW
    Else
    ExitLoop
    EndIf
    EndLoop
    
    Here's some sample data in case anyone wants to see this problem in action:

    Code: Select all

    1268  Public  Datalist: WS, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: &LDMERR, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: SERVRLOG, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: CCDPRES, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: MFCTRL, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: PRSCUST, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: WIP, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: ACCTOWNR, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: NASPECL, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: NATRK, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: NARESOLU, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: NALIEN, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: CHKORDER, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: STARTCHK, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    1268  Public  Datalist: NACTRL, Owner: SYSTEM_S_01f1058e, Time: 09464487 
    

    206
    MasterMaster
    206

      Apr 19, 2005#2

      Nested loops aren't supported. Would be nice.

      Maybe if you furnish some before/after samples with an explanation of what you need to do, some forum regex guru will figure out a way to do it with find/replace code - a thousand times faster than a looping macro.
      Software For Metalworking
      http://closetolerancesoftware.com

      3
      NewbieNewbie
      3

        Apr 19, 2005#3

        Figured nested loops weren't supported, so I already created a macro to call my macro--problem solved.

        I don't think I could do it with find/replace...I'm moving portions around and padding the field after "Datalist: " to eight characters. Plus, in my second macro, I programmed it to find the beginning of these entries and process to the end of the section--that way all I have to do is put my cursor somewhere in the list and hit my macro hotkey. Takes a few seconds to process a big list, but in the end I go from

        Code: Select all

        1268  Public  Datalist: WS, Owner: SYSTEM_S_01f1058e, Time: 09464487 
        1268  Public  Datalist: &LDMERR, Owner: SYSTEM_S_01f1058e, Time: 09464487 
        1268  Public  Datalist: SERVRLOG, Owner: SYSTEM_S_01f1058e, Time: 09464487 
        
        to the easier to read and sort

        Code: Select all

        Owner: SYSTEM_S_01f1058e, Datalist: WS      , Public  
        Owner: SYSTEM_S_01f1058e, Datalist: &LDMERR , Public  
        Owner: SYSTEM_S_01f1058e, Datalist: SERVRLOG, Public  

        206
        MasterMaster
        206

          Apr 19, 2005#4

          Just for fun I put this together. Not suggesting it will cover all the bases, but it looks to work on your sample. It processed a megabyte of your sample text in four seconds on my P4-2.4. Search and replace is like lightning with UE.


          InsertMode
          ColumnModeOff
          HexOff
          UnixReOn
          Top
          Find RegExp "^[0-9][0-9][0-9][0-9] *"
          Replace All ""
          Top
          Find RegExp " *Time.*$"
          Replace All ""
          Top
          Find RegExp "^(Public)( *)(Datalist.*)$"
          Replace All "\3\1"
          Top
          Find RegExp "^(Data.*,) *(Owner.*,)(.*)$"
          Replace All "\2\1\3"
          Top
          Find ",Datalist"
          Replace All ", DataList"
          Top
          Find RegExp "DataList: (.)(.),"
          Replace All "DataList: \1\2 ,"
          Top
          Find RegExp "DataList: (.)(.)(.),"
          Replace All "DataList: \1\2\3 ,"
          Top
          Find RegExp "DataList: (.)(.)(.)(.),"
          Replace All "DataList: \1\2\3\4 ,"
          Top
          Find RegExp "DataList: (.)(.)(.)(.)(.),"
          Replace All "DataList: \1\2\3\4\5 ,"
          Top
          Find RegExp "DataList: (.)(.)(.)(.)(.)(.),"
          Replace All "DataList: \1\2\3\4\5\6 ,"
          Top
          Find RegExp "DataList: (.)(.)(.)(.)(.)(.)(.),"
          Replace All "DataList: \1\2\3\4\5\6\7 ,"
          Top
          Find RegExp "DataList: (.)(.)(.)(.)(.)(.)(.)(.),"
          Replace All "DataList: \1\2\3\4\5\6\7\8, "
          Software For Metalworking
          http://closetolerancesoftware.com

          3
          NewbieNewbie
          3

            Apr 20, 2005#5

            Sweet. Thanks Michael.