PowerDesign? Does it feel very old, just used to it.
The following code is compiled with reference to the network, and has been optimized and tested by myself.
==>name to code
name format: Chinese# code
.set_value(_First, true, new)
.foreach_part(%Name%, "'#'")
.if (%_First%)
.delete(%CurrentPart%)
.set_value(_First, false, update)
.else
%CurrentPart%
.endif
.foreach_part(%Name%, "'#'")
.if (%_First%)
.delete(%CurrentPart%)
.set_value(_First, false, update)
.else
%CurrentPart%
.endif
.next
The method used in PowerDesigner is: PowerDesigner->Tools->Model Options->NamingConvention->name [Enable name/code Conventions]->name to code
==>name to comment
name format: Chinese#code
Change the text before the ## of the table name to the comment of the table, and the text before the ## of the column name to the comment of the column.
The original code is to operate on all tables (and other views, etc.) under a folder (CDM or PDM). Instead, it can only operate on a specific table. If the tabname has a value, it will match the tabname value, otherwise if the tabname is If empty, operate on all tables.
The method used in PowerDesigner is: PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
-----------------------------------------------------------------------------
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim tabname
Dim mdl ' the current model
'如果tabname留空,则对所有表进行操作
tabname = "应答推荐"
' 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
dim cando
cando = 1
if tabname<>"" and Instr(tab.name, tabname) = 0 then
cando = 0
end if
'msgBox tab.name
'msgBox cando
if not tab.isShortcut and cando=1 then
InteractiveMode = im_Batch
Dim tabname
Dim mdl ' the current model
'如果tabname留空,则对所有表进行操作
tabname = "应答推荐"
' 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
dim cando
cando = 1
if tabname<>"" and Instr(tab.name, tabname) = 0 then
cando = 0
end if
'msgBox tab.name
'msgBox cando
if not tab.isShortcut and cando=1 then
msgBox "The following table is about to be operated:"&tab.name
tab.comment = split(tab.name ,"#")(0)
Dim col ' running column
for each col in tab.columns
col.comment= split(col.name,"#")(0)
msgBox col.comment
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = split(view.name,"#")(0)
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
for each col in tab.columns
col.comment= split(col.name,"#")(0)
msgBox col.comment
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.comment = split(view.name,"#")(0)
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