Merge a line with an other line 3 lines above?

Merge a line with an other line 3 lines above?

10
Basic UserBasic User
10

    Dec 11, 2006#1

    From time to time I get stucked in problems that I cant solve on my own. The good thing is that I have always got help on this forum, and I hope that somone can help me with this problem too.

    I have a log- file that contains several "warnings" and "fails", the problem is that the warning/fail does not connect to the "string" which is 3 lines above, so the information is no good for further actions.

    What I'm trying to do is to find all the warnings/Fails, which always starts with A: or F: - then I whant to hook this up with the "string" 3 lines above.
    Maybe the example explains this better.

    * 5120061206xX99999Www9999261A288887  navnn       2001390000932294346navn
    * navn                 adre 11                       4515100210119200612
    * 06322 00243001830003222014500K113000050400                    0000000000000
    * A:8208 Ufullstendige data om
    *    Dette medfører at kun dato vvvvvvvvvvvvvvvvvv utland leses inn
    *    merke: xxxxxxx vvvvvvv.nr Www2200261A299907 Dato

    What I'm hoping for is to find/create a macro that searches for all A: and F: in a file, and then put them together in one string, line by line like this

    A:8208 Ufullstendige data om 5120061206xX99999Www9999261A288887  navnn       2001390000932294346navn
    F:1500   example example      5211111111111111111111111111111111
    A:15000 example                   5122222222222222222222222222222222

    6,675585
    Grand MasterGrand Master
    6,675585

      Dec 11, 2006#2

      The macro property Continue if a Find with Replace not found must be checked for this macro.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Bottom
      IfColNumGt 1
      "
      "
      EndIf
      Top
      Clipboard 9
      ClearClipboard
      Loop
      Find MatchCase RegExp "%^* [AF]:[0-9]+*$"
      IfFound
      StartSelect
      CopyAppend
      EndSelect
      Key UP ARROW
      Key UP ARROW
      Key UP ARROW
      StartSelect
      SelectLine
      CopyAppend
      EndSelect
      Key DOWN ARROW
      Key DOWN ARROW
      Key DOWN ARROW
      Else
      ExitLoop
      EndIf
      EndLoop
      NewFile
      UnicodeToASCII
      UnixMacToDos
      Paste
      Top
      Find RegExp "%^* "
      Replace All ""
      Find "* "
      Replace All " "
      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

      10
      Basic UserBasic User
      10

        Dec 13, 2006#3

        Thanks alot, this macro worked just fine :D When I ran the macro I saw things that I haven't thought about. The length of the text after A and F is variable. Is it possible to give in a col where all of the records starts (the line 3 lines above), this would have made it easier to import the file into a database.

        A:15000 texttexttexttext ---------------512006111111111111
        F:3050 texttext --------------------------522006111111111111
        A:8002 texttexttexttexttexttexttext----542006111111111111

        Anyway thanks again for great help for a fantastic product :D[

        6,675585
        Grand MasterGrand Master
        6,675585

          Dec 13, 2006#4

          Same macro as above, but now with alignment on column 50.

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          Bottom
          IfColNumGt 1
          "
          "
          EndIf
          Top
          Clipboard 9
          ClearClipboard
          Loop
          Find MatchCase RegExp "%^* [AF]:[0-9]+*$"
          IfFound
          StartSelect
          CopyAppend
          EndSelect
          Key UP ARROW
          Key UP ARROW
          Key UP ARROW
          StartSelect
          SelectLine
          CopyAppend
          EndSelect
          Key DOWN ARROW
          Key DOWN ARROW
          Key DOWN ARROW
          Else
          ExitLoop
          EndIf
          EndLoop
          NewFile
          UnicodeToASCII
          UnixMacToDos
          Paste
          Top
          Find RegExp "%^* "
          Replace All ""
          Find "* "
          Replace All "                                 "
          Bottom
          Key BACKSPACE
          Loop 250
          " "
          EndLoop
          Top
          Loop 49
          Key RIGHT ARROW
          EndLoop
          ColumnModeOn
          StartSelect
          SelectToBottom
          ColumnLeftJustify
          EndSelect
          ColumnModeOff
          Bottom
          "
          "
          Top
          TrimTrailingSpaces

          ClearClipboard
          Clipboard 0

          The macro now replaces the string "* " with a big number of spaces. Best would be to have 50 spaces for alignment on column 50 in this string.

          Next it deletes the last line termination in the file and makes the last line the longest line in the file by inserting 250 spaces at end of the file. Use a higher number if necessary.

          Back at top of the file the cursor is moved to column 50 with the old method. Since UE v12.20a+2 instead of the Loop the command GotoLine 1 50 could be also used.

          Now the column mode is enabled and everything from current cursor position to end of the file is selected. ColumnLeftJustify moves all strings to the column 50.

          Finally column mode is turned off, the trailing spaces are removed and the last line of the file is again terminated with line termination character(s).
          Best regards from an UC/UE/UES for Windows user from Austria

          10
          Basic UserBasic User
          10

            Dec 29, 2006#5

            I never got to thank you for helping me once again - The macro works just the way I hoped it would, so thank you very much :D