How to "find in file" and "copy to file"

How to "find in file" and "copy to file"

2
NewbieNewbie
2

    Nov 09, 2005#1

    I have a pb :
    I have to find in a file every line between 2 positions. In fact, the line juste after "PARSING IN CURSOR" and juste before "END OF STMT".
    I have 2 solutions :
    1/ I delete all the lines that is not between my 2 "expressions", include thes 2 lines.
    2/ I fetch the line between this 2 "expressions" and save it in a new file. This is the best solution, i guess !

    Exemple:

    Original:

    APPNAME mod='FXMEXPLR' mh=3136364418 act='' ah=4029777240
    =====================
    PARSING IN CURSOR #29 len=64 dep=0 uid=10247 oct=3 lid=10247 tim=1105006329960485 hv=1880456616 ad='14c13620'
    SELECT SCE_VPD.SCE_CONTEXT('multicompany','company') FROM DUAL
    END OF STMT
    EXEC #29:c=0,e=86,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=2,tim=1105006329843848
    =====================
    PARSING IN CURSOR #22 len=41 dep=1 uid=10249 oct=3 lid=10249 tim=1105006329978565 hv=1006647865 ad='12852700'
    SELECT SYS_CONTEXT(:B2,:B1) FROM SYS.DUAL
    END OF STMT
    EXEC #22:c=0,e=104,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=2,tim=1105006329978559
    FETCH #22:c=0,e=97,p=0,cr=3,cu=0,mis=0,r=1,dep=1,og=2,tim=1105006329978753
    FETCH #29:c=0,e=18284,p=0,cr=6,cu=0,mis=0,r=1,dep=0,og=2,tim=1105006329978869
    RPC CALL:SCE.PL_FUNC.GET_TOKEN;
    RPC EXEC:c=0,e=9060
    RPC CALL:SCE.PL_FUNC.GET_TOKEN;
    RPC EXEC:c=0,e=71
    =====================

    What i Want to have:
    SELECT SCE_VPD.SCE_CONTEXT('multicompany','company') FROM DUAL
    =====================
    SELECT SYS_CONTEXT(:B2,:B1) FROM SYS.DUAL


    I'm not familiar with the macro, and what i done did not give a result.

    Can someone help me :)

    THKX,

    =========================
    Greating from Marseille, France

    6,675585
    Grand MasterGrand Master
    6,675585

      Nov 10, 2005#2

      This macro should do the job. I now have no time to write a explanation how it works, sorry!

      InsertMode
      ColumnModeOff
      HexOff
      Clipboard 9
      ClearClipboard
      Top
      Bottom
      IfColNum 1
      Else
      "
      "
      EndIf
      Top
      Loop
      Find MatchCase "PARSING IN CURSOR"
      IfNotFound
      ExitLoop
      EndIf
      EndSelect
      Key HOME
      Key DOWN ARROW
      StartSelect
      Find MatchCase Select "END OF STMT"
      Key HOME
      CopyAppend
      EndSelect
      Key HOME
      Find "=====================^p"
      CopyAppend
      EndSelect
      Key HOME
      EndLoop
      Top
      NewFile
      Paste
      Top
      NextWindow
      CopyFilePath

      CloseFile NoSave
      Open "^c"

      PreviousWindow
      "
      "
      Key UP ARROW
      Paste
      Key END
      Find Up Select "\"
      Delete
      "\azerty.txt"
      SelectToTop
      Cut
      Key DEL
      SaveAs "^c"

      ClearClipboard
      Clipboard 0

      Edit: Improved macro code as requested!
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Nov 10, 2005#3

        Thankx a lot Mofi,
        It's work nice, but i would like to copy the clipboard in a new file named "azerty.txt",for exemple, instead of saving the result to the clipboard.

        Do you have any idea how to copy the clipboard to a new file (azerty.txt), and redirecting the the result adding the path to the file to be saved.

        Thkx ,

        Salem

        6,675585
        Grand MasterGrand Master
        6,675585

          Nov 10, 2005#4

          Please check in the macro properties for this macro the option Continue if a Find with Replace not found. Now the macro will not simply stop when the search string is not found anymore and runs the macro code after EndLoop, which creates a new file and pastes the data collected in the clipboard. Then the macro ends and you can save the new file manually to whatever you want.

          I have also modified the macro code with additonal lines to automatically save the new file to what you suggested - see green lines above.

          Also the source file is closed without save and reopened to discard possible temporary modifications created by the macro (insert a line break at end of the file, if last line does not already have one). Delete the red lines, if you don't like this.
          Best regards from an UC/UE/UES for Windows user from Austria