广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    Visual Fortran如何添加多行注释

    来源:网络收集  点击:  时间:2024-08-07
    【导读】:
    经常用Fortran编程的同学肯定会遇到这样一个问题,想对多行代码进行注释,但原装软件没有批量注释功能,只能一行一行的注释。那么有没有一种方便快捷的方法进行批量注释呢?of cuurse,现在就教你如何轻松实现这个功能。工具/原料moreCompaq Visual Fortran软件电脑方法/步骤1/6分步阅读

    在软件安装文件夹下,如C盘:C/Program Files/Microsoft Visual Studio/Common/MSDEV98/MACROS文件夹下生成文件GrpComment.dsm

    2/6

    用文本编辑器打开该文件,将以下代码粘贴保存在其中,并保留.dsm后缀名

    Function FileType (ByVal doc)

    ext = doc.Name FileType = 0 pos = Instr(ext, .) if pos 0 then Do While pos 1 ext = Mid(ext, pos, Len(ext) - pos + 1) pos = Instr(ext, .) Loop ext = LCase(ext) end if If ext = .f90 Then FileType = 8 ElseIf ext = .for Then FileType = 9 Else FileType = 0 End If End Function Sub CommentOut () DESCRIPTION: 为所选的多行代码加注释 Dim win set win = ActiveWindow if win.type Text Then MsgBox This macro can only be run when a text editor window is active. else TypeOfFile = FileType(ActiveDocument) If TypeOfFile = 8 Or TypeOfFile = 9 Then If TypeOfFile = 8 Then CommentType = ! Fortran 90 file Else CommentType = C Fortran 77 file End If StartLine = ActiveDocument.Selection.TopLine EndLine = ActiveDocument.Selection.BottomLine If EndLine StartLine Then Temp = StartLine StartLine = EndLine EndLine = Temp End If If EndLine = StartLine Then ActiveDocument.Selection.SelectLine ActiveDocument.Selection = CommentType + ActiveDocument.Selection Else For i = StartLine To EndLine ActiveDocument.Selection.GoToLine i ActiveDocument.Selection.SelectLine ActiveDocument.Selection = CommentType + _ ActiveDocument.Selection Next End If else MsgBox(Unable to comment out the highlighted text + vbLf + _ because the file type was unrecognized. + vbLf + _ If the file has not yet been saved, + vbLf + _ please save it and try again.) End If End If End Sub Sub CommentDel () DESCRIPTION: 去除所选的多行代码的注释 Dim win set win = ActiveWindow if win.type Text Then MsgBox This macro can only be run when a text editor window is active. else TypeOfFile = FileType(ActiveDocument) If TypeOfFile = 8 Or TypeOfFile = 9 Then StartLine = ActiveDocument.Selection.TopLine EndLine = ActiveDocument.Selection.BottomLine If EndLine StartLine Then Temp = StartLine StartLine = EndLine EndLine = Temp End If If EndLine = StartLine Then ActiveDocument.Selection.SelectLine ActiveDocument.Selection = mid(ActiveDocument.Selection, 3) Else For i = StartLine To EndLine ActiveDocument.Selection.GoToLine i ActiveDocument.Selection.SelectLine ActiveDocument.Selection = mid(ActiveDocument.Selection, 3) Next End If else MsgBox(Unable to comment out the highlighted text + vbLf + _ because the file type was unrecognized. + vbLf + _ If the file has not yet been saved, + vbLf + _ please save it and try again.) End If End If End Sub

    3/6

    启动Fortran,选Tools-Customize-Add-ins and Macro Files,在GrpComment前打勾,去掉其他的勾

    4/6

    在同一对话框中选Commands-Macros,此时在右边可以看见CommentDel和CommentOut

    5/6

    选中CommentOut,拖到CVF的工具栏上去(添加工具钮),会弹出Button Appearance对话框;同理选中CommentDel并拖动到工具栏,也会弹出该对话框。

    6/6

    对话框中有三种显示模式,分别是:图标展示、文本展示和图文展示。结合自己的偏好选择不同的模式,最后点“OK”键就可以使用啦。

    在编程过程中,选取多行代码,然后点击刚刚设置好的快捷按钮,即可对多行代码进行注释。

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1076719.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-05 23:53:09  耗时:0.029
    0.0291s