Hello,
I would like to instrument my code by adding some lines at beginning of every procedure in current file. I found some examples here on how to find the current procedure name (CnOtaGetCurrentProcedure) and to add text at cursor position (IdeInsertTextIntoEditor) but I can't find how to add text at the very beginning of a procedure nor how to find each procedure in a file.
Do you have some clues on which methods I can use from CnWizards or the OTA API to do that ?
Here is my current code :
program InsertLogger;
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
var
  EditView: IOTAEditView;
  Proc, O, M: string;
  DotPos: Integer;
begin
  EditView := CnOtaGetTopMostEditView(nil);
  if EditView <> nil then
    EditView.GetPosition.MoveBOL; // Move the cursor to the beginning of the line
  proc := CnOtaGetCurrentProcedure;
  DotPos := Pos('.', proc);
  if DotPos > 0 then //remove the class name if it is present
  begin
    O := Copy(Proc, 1, DotPos - 1);
    M := Copy(Proc, DotPos + 1, MaxInt);
  end;
  IdeInsertTextIntoEditor(Format(
    '{$IFDEF CONSOLEAPP}' + #13#10 +
    '  Log(''%s/%s : VERIFY !'');' + #13#10 +
    '{$ENDIF}' + #13#10, [
      O, M
    ])
  );
end.
Regard,
-- 
Pierre Y.