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