替换规则:
由于本人觉得commit的注释有些比较长,就写在()里面,转换的时候,只能()左边的
如comment '用户类型(1,企业;2,个人)'
转换后name为 用户类型
如何运行此脚本:
在生成的PDM中, Powerdesigner界面-tools-Execute Cmmands-Edit/Run Scripts 在打开的界面中,左上角,选择打开,Ctrl+O,选取刚才的Comments2Name.vbs,并Run,效果同上
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' the current model ' get the current active 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 'running table for each Tab in folder.tables if not tab.isShortcut then tab.name = tab.comment Dim col ' running column for each col in tab.columns if col.comment="" then else col.name = left(col.comment, InStr(col.comment,"(")-1) end if next end if next Dim view 'running view for each view in folder.Views if not view.isShortcut then view.name = view.comment end if next ' go into the sub-packages Dim f ' running folder For Each f In folder.Packages if not f.IsShortcut then ProcessFolder f end if Next end sub