diff --git a/components/codetools/examples/addfpprofcalls.lpr b/components/codetools/examples/addfpprofcalls.lpr index fb4484c4f3..7d150f7ef0 100644 --- a/components/codetools/examples/addfpprofcalls.lpr +++ b/components/codetools/examples/addfpprofcalls.lpr @@ -64,6 +64,43 @@ var FromPos: objpas.Integer; ToPos: objpas.Integer; +procedure ShowHelp; +begin + writeln('addfpprofcalls'); + writeln; + writeln('List function signatures, or add or remove fpprofiler calls to selected functions.'); + writeln; + writeln('Usage: ...'); + writeln(' -h : write this help'); + writeln(' -r : remove calls instead of list'); + writeln(' -a : add calls instead of list'); + writeln; + writeln('Example'); + writeln(' List all function signatures of unit1.pas'); + writeln(' ',ParamStrUTF8(0),' unit1.pas'); + writeln(' Add fpprofiler calls to TForm.Button1Click:'); + writeln(' ',ParamStrUTF8(0),' -a unit1.pas TForm1.Button1Click(:TObject)'); + writeln(' Remove fpprofiler calls from TForm.Button1Click:'); + writeln(' ',ParamStrUTF8(0),' -r unit1.pas TForm1.Button1Click(:TObject)'); + writeln; + writeln('Before:'); + writeln('======='); + writeln('procedure TMainForm.Button1Clicked(...)'); + writeln('begin'); + writeln(' // do something here'); + writeln('end;'); + writeln; + writeln('After:'); + writeln('======'); + writeln('procedure TMainForm.Button1Clicked(...)'); + writeln('begin'); + writeln(' SendMethodEnter(''TMainForm.Button1Clicked'');'); + writeln(' // do something here'); + writeln(' SendMethodExit(''TMainForm.Button1Clicked'');'); + writeln('end;'); + writeln; +end; + procedure RemoveCall; begin FromPos:=Tool.CurPos.StartPos; @@ -98,39 +135,8 @@ begin for i:=1 to ParamCount do begin Param:=ParamStrUTF8(i); if (Param='-h') or (Param='-?') then begin - writeln('addfpprofcalls'); - writeln; - writeln('List function signatures, or add or remove fpprofiler calls to selected functions.'); - writeln; - writeln('Usage: ...'); - writeln(' -h : write this help'); - writeln(' -r : remove calls instead of list'); - writeln(' -a : add calls instead of list'); - writeln; - writeln('Example'); - writeln(' List all function signatures of unit1.pas'); - writeln(' ',ParamStrUTF8(0),' unit1.pas'); - writeln(' Add fpprofiler calls to TForm.Button1Click:'); - writeln(' ',ParamStrUTF8(0),' -a unit1.pas TForm1.Button1Click(:TObject)'); - writeln(' Remove fpprofiler calls from TForm.Button1Click:'); - writeln(' ',ParamStrUTF8(0),' -r unit1.pas TForm1.Button1Click(:TObject)'); - writeln; - writeln('Before:'); - writeln('======='); - writeln('procedure TMainForm.Button1Clicked(...)'); - writeln('begin'); - writeln(' // do something here'); - writeln('end;'); - writeln; - writeln('After:'); - writeln('======'); - writeln('procedure TMainForm.Button1Clicked(...)'); - writeln('begin'); - writeln(' SendMethodEnter(''TMainForm.Button1Clicked'');'); - writeln(' // do something here'); - writeln(' SendMethodExit(''TMainForm.Button1Clicked'');'); - writeln('end;'); - Halt; + ShowHelp; + exit; end else if Param='-r' then Mode:=mRemove else if Param='-a' then @@ -146,6 +152,11 @@ begin end; end; + if Filename='' then begin + ShowHelp; + exit; + end; + // load the file Code:=CodeToolBoss.LoadFile(Filename,false,false); if Code=nil then