How to insert a line at start and end of a procedure?

How to insert a line at start and end of a procedure?

1
NewbieNewbie
1

    Dec 06, 2006#1

    Hi there,

    I do not get the trick for the following task. Maybe anyone could help me out? I got a file that looks like

    Code: Select all

    Private Function1(Param1, Param2)
      Some Code
      Some More Code
    End Function
    
    Private Function2(Param1, Param2)
      Some Code
      Some More Code
    End Function
    I'd like to add some text after the line Private Function... and some text befor the line End Function. so it look like that

    Code: Select all

    Private Function1(Param1, Param2)
      Trace("Function1")
      Some Code
      Some More Code
      EndTrace("Function1")
    End Function
    
    Private Function2(Param1, Param2)
      Trace("Function2")
      Some Code
      Some More Code
      EndTrace("Function2")
    End Function
    As you see, it would be great if the insertet text Trace("Function2") and EndTrace("Function1") hase the name of the function he is inserted to.

    Some ideas? Many thanks in advance!
    kai

    6,687587
    Grand MasterGrand Master
    6,687587

      Dec 07, 2006#2

      This macro was created by simply recording a manual execution and then edited it a little (Loop, ExitLoop, ClearClipboard, ...). Maybe it's not perfect for you, but it works perfect for your example.

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

      InsertMode
      ColumnModeOff
      HexOff
      Clipboard 9
      Loop
      Find MatchCase "Private"
      IfNotFound
      ExitLoop
      EndIf
      EndSelect
      Key Ctrl+RIGHT ARROW
      StartSelect
      SelectWord
      Copy
      EndSelect
      Key HOME
      Key DOWN ARROW
      " Trace(""
      Paste
      "")
      "
      Find MatchCase "End Function"
      Key HOME
      " EndTrace(""
      Paste
      "")
      "
      EndLoop
      ClearClipboard
      Clipboard 0
      Best regards from an UC/UE/UES for Windows user from Austria