最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

FROTRAN 多行注释 添加方法

来源:动视网 责编:小OO 时间:2025-09-25 21:51:36
文档

FROTRAN 多行注释 添加方法

在CVF中为多行代码加注释。CVF本身无这样的功能,但是可以用macro功能自己添!而且是添加工具钮!做法:(1)在..\\MicrosoftVisualStudio\\Common\\MSDEV98\\MACROS文件夹下生成文件GrpComment.dsm(2)用文本编辑器打开该文件,将以下所附的代码贴在其中,保存(注意保留.dsm后缀)(3)启动CVF,选Tools=>Customize=>Add-insandMacroFiles(4)在GrpComment前打勾,去掉其他的勾(5)在同
推荐度:
导读在CVF中为多行代码加注释。CVF本身无这样的功能,但是可以用macro功能自己添!而且是添加工具钮!做法:(1)在..\\MicrosoftVisualStudio\\Common\\MSDEV98\\MACROS文件夹下生成文件GrpComment.dsm(2)用文本编辑器打开该文件,将以下所附的代码贴在其中,保存(注意保留.dsm后缀)(3)启动CVF,选Tools=>Customize=>Add-insandMacroFiles(4)在GrpComment前打勾,去掉其他的勾(5)在同
在CVF中为多行代码加注释。

CVF本身无这样的功能,但是可以用macro功能自己添!而且是添加工具钮!

做法:

(1) 在..\\Microsoft Visual Studio\\Common\\MSDEV98\\MACROS文件夹下生成文件GrpComment.dsm

(2) 用文本编辑器打开该文件,将以下所附的代码贴在其中,保存(注意保留.dsm后缀)

(3) 启动CVF,选Tools=>Customize=>Add-ins and Macro Files

(4) 在GrpComment前打勾,去掉其他的勾

(5) 在同一对话框中选Commands=>Macros,此时在右边可以看见CommentDel和CommentOut

(6) 选中CommentOut,拖到CVF的工具栏上去(添加工具钮),会弹出Button Appearance对话框

(7) 选Image and text,在下边Button text框中输入名称(默认是CommentOut),如“加注释”

(8) 类似的方法再将CommentDel命令以工具钮的形式添加到工具栏上,名称可取为“去注释”

这时,工具栏上应该多了两个工具钮:“加注释”和“去注释”。

用法:

加注释:选择要加注释的多行代码,点击“加注释”按钮即可;

去注释:选择已经注释的多行代码,点击“去注释”按钮即可。

适用:后缀为f90或f77的代码文件。

!----------------------------------------------------------------------

VBscript代码:

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

!----------------------------------------------------------------------