IDE 如 Eclipse、Dev-C++ 內建檔案範本支援變數替換,VC6.0 雖無內建功能,但可透過巨集錄製達成同樣效果。
/** * Name: * Copyright: * Author: * Date: 2008-4-18 21:54:32 * Description: * Modification: **/
FILECOMMENT。Ctrl+E。
Sub FILECOMMENT()
'DESCRIPTION: COMMENT For file version
ActiveDocument.Selection = "/**"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Name: "
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Copyright: "
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Author: "
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Date: "
ActiveDocument.Selection = Date + " " + Time ' 自動插入當前日期時間
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Description: "
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " * Modification: "
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = " **/"
End Sub
ActiveDocument.Selection = " * File: " + ActiveDocument.Name 自動帶入檔名。InputBox 讓使用者輸入作者、版權等資訊。$Author$, $Date$)。自此,新建檔案按 Ctrl+E 即可插入標準註解,提升團隊程式碼規範一致性。