Powerdesigner tip set 5-Use Vbscript to import the content in TXT text to the PDM Model

Source: Internet
Author: User
Tags powerdesigner

The following script uses VBScript to import the content in the TXT text to the PDM model.

Option explicitdim system, fileset system = Createobject ("scripting. fileSystemObject ") dim forreading, forwriting, forappendingdim strdim titledim firstforreading = 1' sets File Read-Only forwriting = 2' sets file write forappending = 8' sets file append set file = system. opentextfile ("E: \ Users \ hxw \ Desktop \ VBScript \ tab.txt", forreading) 'Open the text document dim nolinedim tab 'to define a table. The variables in VBScript are not of such strict type, however, this variable will be used to indicate that tablevalidationmode = truedim MDL 'will define the currently activated model, that is, mdldim coldim DM, dmstrdim sssdim isnewtableset MDL = activemodel' to obtain the current activation model set tab = MDL. tables. createnewisnewtable = truefirst = file. readline'read document row-based read Title = Split (first) 'is divided into arrays by space. The table attributes are obtained and more attributes can be obtained, depends on the actual situation. name = title (0) 'nametab. code = title (1) 'codetab. comment = title (2) 'commentdo while file. atendofstream <> true' reads every line of the document cyclically. Sss = file. readline STR = Split (SSS) if SSS <> "" Then isnewtable = false else isnewtable = true end if isnewtable = true thenfirst = file. readline' read document read by row Title = Split (first) Set Tab = MDL. tables. createnew: Create a new table. This is the result of reading empty rows. You can use it to warn the tab. name = title (0) 'nametab. code = title (1) 'codetab. comment = title (2) 'commentelseset Col = tab. columns. createnew 'create a row of field Col. name = STR (0) 'is used to set attributes in sequence. For attributes of the same table, you can also set more attributes for fields. Col. code = STR (0) Col. datatype = STR (2) Col. comment = STR (3) end ifloopfile. close

The content of tab.txt is as follows:

Table Name 1 Table code1 table comments1
Field name 1 mycode1 varchar2 (32) description 1
Field name 2 mycode2 varchar2 (256) Description 2

Table name 2 Table code2 table comments2
Field name 1 mycode1 varchar2 (32) description 1
Field name 2 mycode2 varchar2 (256) Description 2

 

 

 

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.