强者征服今天,懦夫哀叹昨天,懒汉坐等明天。
|

【转】PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

★作者:Star   |  ★类别: 技术文章   |  ★发布时间: 2013-09-07 16:20   |  ★更新时间: 2013-09-07 16:37   |  ★浏览次数:5215   |  ★ 评论(0)

在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Description中,有时候我们写好了Name再写一次Comment很麻烦.以下两段代码就可以解决这个问题.

 代码一:将Name中的字符COPY至Comment中:

'******************************************************************************
'*   File:           name2comment.vbs
'*   Purpose:     Database   generation   cannot   use   object   names   anymore  
'                         in   version   7   and   above.
'                         It   always   uses   the   object   codes.
'
'                         In   case   the   object   codes   are   not   aligned   with   your  
'                         object   names   in   your   model,   this   script   will   copy  
'                         the   object   Name   onto   the   object   Comment   for  
'                         the   Tables   and   Columns.
'
'*   Title:        
'*   Version:     1.0
'*   Company:     Sybase   Inc.  
'******************************************************************************


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

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view
'   of   the   current   folder
Private   sub   ProcessFolder(folder)
      Dim   Tab   'running     table
      for   each   Tab   in   folder.tables
            if   not   tab.isShortcut   then
                  tab.comment   =   tab.name
                  Dim   col   '   running   column
                  for   each   col   in   tab.columns
                        col.comment=   col.name
                  next
            end   if
      next

      Dim   view   'running   view
      for   each   view   in   folder.Views
            if   not   view.isShortcut   then
                  view.comment   =   view.name
            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


 

代码二:将Comment中的字符COPY至Name中 

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=   col.comment
                  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


 

请尊重他人的劳动果实,转载时务必注明出处! 请尊重他人的劳动果实,转载时务必注明出处!
转载请注明:文章转载自:桐星豆 [https://txdou.com]
本文标题:【转】PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
本文地址:https://txdou.com/article92
分享到QQ空间 分享到腾讯朋友

  • 注意:“桐星豆”只会以“回复”的身份出现,不会以“咨询”的身份出现在留言或评论中,凡是以“咨询”的身份出现的留言或评论均为他人盗用!
  • 本站用以回复网友评论的唯一名称是“桐星豆”,除此外均无效,网友不得用此名进行相应文章的评论或回复!
  • 用户言论只代表其个人观点,不代表桐星豆的观点或立场!
  • 非诚勿扰,请友好如实的评论,杜绝谩骂、人格攻击等一切伤人言论,请严格遵循中华人民共和国法律法规!
  • 桐星豆拥有最终解释权,如有网友违规,本站将有权删除或屏蔽违规评论,情节严重者账户加入黑名单、永久封IP并报司法部门严惩!
  • 您一旦参与评论本站则默认为您已经同意以上条款,否则“非诚勿扰”,谢谢合作!

您的姓名或昵称: 选填
您的E-Mail地址: ☆必填--仅站长可见
您个人网站地址: 选填 ( 如果填写,请务必加上 http:// 或 https:// 等等 )
留言内容:

验证码: 点击重新生成验证码  [ ctrl + enter ]

CopyRight © 2009-2024 by 桐星豆 All Rights Reserved. ICP证:京ICP备20021364号
Star-2023-02-07-SSO