• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

代码格式化脚本CodeFormat

发布: 2007-7-01 20:40 | 作者: admin | 来源: | 查看: 13次 | 进入软件测试论坛讨论

领测软件测试网

没学过VBSript,但为了格式化自己要用的代码,找来找去没找到合适的,勉强作了一个。用法:将下面代码存成一个“.DSM”后缀的文件,用VC6装载这个宏,打开任一C,C++代码文件,运行宏,代码将按系统设置的方式(空格或TAB)得到格式化。由于不懂VBSript,做得不完善,问题是:1:必须把欲格式化的文件在VC等环境下打开,不能按目录自动检索该格式化的文件;2:在“{”后有字符时{}里面的失去缩进;

条件:文件必须可写。

存在的价值:VC环境是大家信任的环境,绝不会因为它对代码格式化而使代码不能编译。

希望有人不吝技术,把它做好一点。如果有新版,请寄给我一份:

Sub FormatByCode()
 Dim myDocument
 For Each myDocument in Application.Documents
  myDocument.Active = True
  myDocument.Selection.SelectAll

  Dim EndLine, CurrLine
  EndLine=myDocument.Selection.BottomLine
  myDocument.Selection.StartOfLine
  CurrLine=myDocument.Selection.CurrentLine

  while ( CurrLine<=EndLine )
   myDocument.Selection.SelectLine
   myDocument.Selection =  LTrim(myDocument.Selection)
   CurrLine=myDocument.Selection.CurrentLine
  wend

  myDocument.Selection.SelectAll
  myDocument.Selection.Unindent
  myDocument.Selection.Unindent
  myDocument.Selection.Unindent
  myDocument.Selection.Unindent
  myDocument.Selection.Unindent
  myDocument.Selection.Unindent
  myDocument.Selection.SmartFormat
  myDocument.Save
  myDocument.Close dsSaveChangesPrompt
 Next
End Sub


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网