filter out the special paragraph including a keyword

filter out the special paragraph including a keyword

1
NewbieNewbie
1

    Jul 26, 2006#1

    How to write a macro to filter out (or keep ) the special
    paragraph including a keyword?


    I use UEStudio to analyze the output messages of a simulation.

    the trace buffer are something like these:


    -----------------------------------------------------------------------
    ** Event #8656. T= 12 (12.00s). Module #30 `rose.node[27]'
    {{{{{ Node[27]: round(1) handleMessage:[28]-->[-1]:<MSG_SPT_DEGREE>
    Node[27]:handleMessage(): delete msg }}}}}

    ** Event #8657. T= 21 (21.00s). Module #3 `rose.node[0]'
    {{{{{ Node[0]: round(1) handleMessage:<PLAN_CHECK_ALIVE>
    Node[0] remain energy = 1999.95
    Node[0]:handleMessage(): delete msg }}}}}

    ** Event #8658. T= 21 (21.00s). Module #4 `rose.node[1]'
    {{{{{ Node[1]: round(1) handleMessage:<PLAN_CHECK_ALIVE>
    Node[1] remain energy = 1999.98
    Node[1]:handleMessage(): delete msg }}}}}

    -------------------------------------------------------------------------

    In order to make things clear, I'd like to detele all the trivial messages.
    For the above instance, all the messages contain "<PLAN_CHECK_ALIVE>".

    only the following paragraph are kept:

    =======================================================
    ** Event #8656. T= 12 (12.00s). Module #30 `rose.node[27]'
    {{{{{ Node[27]: round(1) handleMessage:[28]-->[-1]:<MSG_SPT_DEGREE>
    Node[27]:handleMessage(): delete msg }}}}}

    =======================================================

    How can I write a macro to achieve this work?

    Say, given a keyword, "PLAN_CHECK_ALIVE", delete the whole paragraph (between
    two space lines) which contain this keyword.

    6,675585
    Grand MasterGrand Master
    6,675585

      Re: filter out the special paragraph including a keyword

      Jul 27, 2006#2

      Enable the macro property Continue if a Find with Replace not found for the following macro without any regular expression search.

      InsertMode
      ColumnModeOff
      HexOff
      Bottom
      IfColNum 1
      "
      "
      Else
      "

      "
      EndIf
      Top
      TrimTrailingSpaces
      Loop
      Find MatchCase "PLAN_CHECK_ALIVE"
      IfNotFound
      ExitLoop
      EndIf
      Find MatchCase Up "** Event"
      EndSelect
      Key HOME
      StartSelect
      Find MatchCase Select "}}}}^p^p"
      Delete
      EndSelect
      EndLoop
      Bottom
      Key BACKSPACE
      Top

      The macro first makes sure that the last line of the file is terminated with a CRLF and also adds an additional blank line after the last paragraph. This must be to delete also the last paragraph if it contains the word PLAN_CHECK_ALIVE.

      Back at top of the file the trailing spaces are deleted to let the 3rd find always find the end of a paragraph without using a regular expression.

      Inside the loop the first find searches for the keyword. If it is not found, the loop exits. If it is found, find upwards the start of the paragraph. Move the cursor to the start of the line and use a third find to select the whole paragraph and the empty line below and delete it.

      Last the added blank line at bottom of the file is deleted.
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        Jul 29, 2006#3

        hello, Mofi
        i am a new learner.
        can you explain more detail about what "^p^p"

        in "Find MatchCase Select "}}}}^p^p"" means?

        6,675585
        Grand MasterGrand Master
        6,675585

          Jul 29, 2006#4

          cwq2008119 wrote:can you explain more detail about what "^p^p"
          It's described in help of UltraEdit/UEStudio in the article about the Find command and also the Replace command. I have already written several times that you shoud read the help articles! Read the manual! You just have to press the Help button in the find or replace dialog. Stop asking such questions!!!!!!!!!!!!!!
          Best regards from an UC/UE/UES for Windows user from Austria