有什麼工具快速刪除delphi原始碼的注釋(文章)?

來源:互聯網
上載者:User
發表於:2008-07-12 17:44:04 樓主
有什麼工具快速刪除delphi原始碼的注釋?有很亂的代碼需要重新整理一遍,單獨刪除太煩。
發表於:2008-07-12 18:04:251樓 得分:1
沒見過,關注
發表於:2008-07-12 18:22:502樓 得分:19
下面的代碼注釋已經被刪了。
測試時Memo1.Text放入含注釋代碼。
Delphi(Pascal) code
            unit Unit1;            interface            uses            Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,            Dialogs, StdCtrls;            type            TForm1 = class(TForm)            Memo1: TMemo;            Button1: TButton;            procedure Button1Click(Sender: TObject);            private            public            end;            var            Form1: TForm1;            implementation            {$R *.dfm}            type            TModalStr = record            rBegin: string;            rEnd: string;            rAppend: string;            rSingle: Byte;            end;            const            cPascalCount = 5;            cPascalList: array[0 .. Pred(cPascalCount)] of TModalStr =            (            (rBegin: ''''; rEnd: '''';   rAppend: '';     rSingle: 1),            (rBegin: '{$'; rEnd: '}';    rAppend: '';     rSingle: 2),            (rBegin: '{';  rEnd: '}';    rAppend: '';     rSingle: 3),            (rBegin: '(*'; rEnd: '*)';   rAppend: '';     rSingle: 4),            (rBegin: '//'; rEnd: #13#10; rAppend: #13#10; rSingle: 5)            );            const            cSQLCount = 4;            cSQLList: array[0 .. Pred(cSQLCount)] of TModalStr =            (            (rBegin: ''''; rEnd: '''';   rAppend: '';     rSingle: 1),            (rBegin: '"';  rEnd: '"';    rAppend: '';     rSingle: 2),            (rBegin: '/*'; rEnd: '*/';   rAppend: '';     rSingle: 3),            (rBegin: '--'; rEnd: #13#10; rAppend: #13#10; rSingle: 4)            );            function GetModalStr(mStr: string; mModalStrList: array of TModalStr;            mSingles: TIntegerSet): string;            var            vSingle: Integer;            I, J: Integer;            T, K: Integer;            vEnd: string;            vAppend: string;            begin            Result := '';            vSingle := 0;            T := 0;            K := 0;            for I := 1 to Length(mStr) do begin            if T > 1 then begin            Dec(T);            Continue;            end;            if vSingle = 0 then begin            vEnd := '';            for J := Low(mModalStrList) to High(mModalStrList) do begin            K := Length(mModalStrList[J].rBegin);            if Copy(mStr, I, K) = mModalStrList[J].rBegin then begin            vEnd := mModalStrList[J].rEnd;            vAppend := mModalStrList[J].rAppend;            vSingle := mModalStrList[J].rSingle;            if vSingle in mSingles then            Result := Result + mModalStrList[J].rBegin;            T := K;            K := Length(vEnd);            Break;            end;            end;            if (vEnd = '') and (vSingle in mSingles) then            Result := Result + mStr[I];            end else if Copy(mStr, I, K) = vEnd then begin            if vSingle in mSingles then            Result := Result + vEnd            else Result := Result + vAppend;            vSingle := 0;            T := K;            end else if vSingle in mSingles then            Result := Result + mStr[I];            end;            end;            procedure TForm1.Button1Click(Sender: TObject);            begin            Memo1.Text := GetModalStr(Memo1.Text, cPascalList, [0, 1, 2]);            end;            end.                        
自己加工一下做個工具,將代碼載入到TStringList中通過Text屬性處理即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.