中易网

如何在visual fortran中一次注释多行代码!

答案:2  悬赏:20  
解决时间 2021-02-15 13:46
如何在visual fortran中一次注释多行代码!
最佳答案
做法:(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的代码文件。Enjoy!!!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 FunctionSub 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 IfEnd SubSub 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 IfEnd Sub
全部回答
建立文件的时候选择fortran77的格式就有粗线的,至于注释,用c或者!开头都可以的
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
刚买的苹果6Plus为什么激活不了老是显示sim卡
有常叫外卖的,又不想整天麻烦熟人点红包链接
急!英国旅游加急签证已经9个工作日了还没下
怎样看洁面乳液里有没有激素
用化学和物理只是解释鸡蛋上浮和下沉的多次原
QQ别人可以改你备注?
要学会游泳的下一句是什么
八闽茶庄在哪里啊,我有事要去这个地方
孩子开学高三,后期作业量特别多,有必要选择
怎样在网上宣传一种东西或者一份工作呢?
孟州市弘鑫农业发展有限公司在什么地方啊,我
地球是否处于第一银行系
小壁虎和苍蝇为什么能在墙壁玻璃和天花板上停
dell 9100 BOSS中文图解
泉州市区附近哪里有奶牛场可以订鲜奶
推荐资讯
宏盛建材商店(富伦街)在什么地方啊,我要过去
红娘牵红线后,就该对两个人的事负责到底,什
朋友们说一下买房贷款保险费需要交吗
画江湖之灵主的男男是谁
轻伤二级不同意派出所调解,该怎么办?谢谢
写热的词语
济和堂药业连锁棕榈分店地址有知道的么?有点
建行信用卡提现什么卡好用
从2007年的美国金融危机到2009年的欧债危机,
北京孩子为何不愿意去外地上大学?
作为一名中学生,你认为应如何实现自己的人生
0.4除以0.3的商是1.5余数是 A 1 B 0.1 C 0.01
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?