VBS code that copies Comment and Name in PowerDesigner

Source: Internet
Author: User

When PowerDesigner is used. it is often used to write Chinese Characters in NAME or Comment and English in Code. the Name will only be shown to us, and the Code will be used in the Code. however, the text in the Comment will be saved to the Description of the Database TABLE. Sometimes it is very troublesome to write the Name again. the following two sections of code can solve this problem.
Code 1: COPY the characters in Name to 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
'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. isw.cut 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. isw.cut 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. isw.cut then
ProcessFolder f
End if
Next
End sub

Code 2: COPY the characters in Comment to 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. isw.cut 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. isw.cut 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. isw.cut then
ProcessFolder f
End if
Next
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.