'******************************************************************************
'* File: comment2name.vbs
'* Author: Jason Chen
'* Created: 2014
'* Modified: 2017/6
'* Version: 2.0
'* Comment: 把表中的描述信息复制为Name,增强可读性
'* Used: 打开物理模型,运行本脚本(Ctrl+Shift+X)
'* Comment:
'****************************************************************************** Option Explicit
ValidationMode = True
InteractiveMode = im_Batch Dim mdl 'the current model '获取当前活动的model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model "
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox "The current model is not an Physical Data model. "
Else
ProcessFolder mdl
End If Private sub ProcessFolder(folder)
On Error Resume Next
'遍历表
Dim Tab
for each Tab in folder.tables
if not tab.isShortcut then
tab.name = tab.code & " " & getName(tab.comment)
Dim col ' running column
for each col in tab.columns
if col.comment="" then
else
col.name = getName(col.comment)
end if
next
end if
next '遍历视图
Dim view
for each view in folder.Views
if not view.isShortcut then
view.name = getName(view.comment)
end if
next '遍历包
Dim f 'running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub '获取名称
Function getName(colComment)
dim index
dim indexArray(10) '排除掉"X"后的文本
indexArray(0) = InStr(colComment, ":")
indexArray(1) = InStr(colComment, vbcrlf)
indexArray(2) = InStr(colComment, ":")
indexArray(3) = InStr(colComment, "(")
indexArray(4) = InStr(colComment, "【")
indexArray(5) = InStr(colComment, "[")
indexArray(6) = InStr(colComment, "(")
indexArray(7) = InStr(colComment, ",")
indexArray(8) = InStr(colComment, " ")
indexArray(9) = InStr(colComment, ":")
index = getArrMinValueIndex(indexArray) if index > 0 then
Output index
getName = Mid(colComment, 1, index-1)
else getName = colComment
end if
end Function '查找最近一个匹配字符的位置
Function getArrMinValueIndex(ByVal arr)
Dim ix, itemMin
itemMin = 0
For ix = 1 To UBound(arr)
If arr(ix) > 0 and (itemMin = 0 or itemMin > arr(ix)) Then
itemMin = arr(ix)
End If
Next
getArrMinValueIndex = itemMin
End Function

  

PowerDesigner中遍历物理模型中的所有表,检查表代码、字段代码的更多相关文章

  1. 【转载】C#中遍历DataTable中的数据行

    在C#中的Datatable数据变量的操作过程中,有时候我们需要遍历DataTable变量获取每一行的数据值,例如将DataTable变量转换为List集合的时候,我们就会遍历DataTable变量, ...

  2. Oracle中使用游标获取指定数据表的所有字段名对应的字符串

    操作步骤:打开PLSQL Developer后,直接执行下面的语句就可以出来 --Oracle中使用游标获取指定数据表的所有字段名对应的字符串 declare mytablename VARCHAR( ...

  3. oracle中查询表的信息,包括表名,字段名,字段类型,主键,外键唯一性约束信息

    来源于网上整理 总结了一下oracle中查询表的信息,包括表名,字段名,字段类型,主键,外键唯一性约束信息,索引信息查询SQL如下,希望对大家有所帮助: 1.查询出所有的用户表select * fro ...

  4. SqlServer中获取所有数据库,所有表,所有字段

    原文:SqlServer中获取所有数据库,所有表,所有字段 一.获取所有数据库 select * from master.dbo.SysDatabases 二.获取某个库中所有表 SELECT * F ...

  5. MySQL 中的数据库名称、数据表名称、字段名称

    如何查询Oracle,Sql Server,MySQL 中的数据库名称.数据表名称.字段名称 分类: Database2012-09-24 22:16 7034人阅读 评论(0) 收藏 举报 数据库s ...

  6. 关于C#中遍历字符串中的每个字符的方法

    解决方案 C#提供了两个方法用于遍历字符串. 1.第一个方法是foreach循环,这个方法快速且容易,但是与第二个方法相比它不太灵活.其使用方法如下: string testStr = "a ...

  7. Python 中遍历序列中元素和下标

    enumerate 函数用于遍历序列中的元素以及它们的下标 for i,v in enumerate(['tic','tac','toe']): print i,v #0 tic #1 tac #2 ...

  8. 查找sqlserver数据库中,查询某值所表名和字段名

    有时候我们想通过一个值知道这个值来自数据库的哪个表以及哪个字段,通过一个存储过程实现的.只需要传入一个想要查找的值,即可查询出这个值所在的表和字段名. 前提是要将这个存储过程放在所查询的数据库. CR ...

  9. ADF中遍历VO中的行数据(Iterator)

    在ADF中VO实质上就是一个迭代器, 1.在Application Module的实现类中,直接借助VO实现类和Row的实现类 TestVOImpl organizationUser = (TestV ...

随机推荐

  1. Mac上如何修改默认打开方式

    1.找到要打开的文件 2.右键显示简介 3.选择默认程序

  2. EF——Guid类型数据的自增长、时间戳和复杂类型的用法 03 (转)

    EF里Guid类型数据的自增长.时间戳和复杂类型的用法   通过前两章Lodging和Destination类的演示,大家肯定基本了解Code First是怎么玩的了,本章继续演示一些很实用的东西.文 ...

  3. 安装TortoiseGit出现提示“您必须安装带有更新版本Windows Installer服务的Windows Service Pack”-解决方法

    我的系统是xp sp3安装TortoiseGit时出现了错误提示“您必须安装带有更新版本Windows Installer服务的Windows Service Pack”. 解决方法,到微软官方下载相 ...

  4. 沈逸老师PHP魔鬼特训笔记(7)--我叫什么名字

    一.生成文件夹. mkdir():--新建目录 bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false ...

  5. easyui window自动居中(修复了iframe弹窗被遮盖问题)

    $.extend($.fn.window.defaults, { onOpen:function(left, top){ var iframeWidth = $(this).parent().pare ...

  6. Shell学习笔记 - 循环语句

    一.for循环 1. 语法格式1 for 变量 in 值1 值2 值3 ... do 程序 done 说明:程序将遍历所有的值,赋值给变量,然后在执行程序.也就是说,后面接多少个值,程序就循环多少次. ...

  7. Umbraco(3) - CSS & Javascript(翻译文档)

    原文地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/umbraco3css-javascript/ CSS & Jav ...

  8. cordova发送邮件插件:ngcordova plugin-Email Composer

    这是ngcordova里边的一个发送邮件的插件,具体的使用方法为: (参考文档:http://ngcordova.com/docs/plugins/emailComposer/) 1.首先下载插件: ...

  9. HDU 4424 Conquer a New Region

    http://acm.hdu.edu.cn/showproblem.php?pid=4424 [题目大意] 给你N个点和N-1条边的连通图,也就是说任意两点间的路径是唯一的.每条边有个权值,从一点到另 ...

  10. 转: Android基于HLS和RTMP协议的第三方SDK选择

    转自: http://isunxu.xyz/android/between-rtmp-and-hls-third-party-choice/ 协议的详解网上资料都太多了,我就不赘述了.Android上 ...