Powerdesigner tip set 6 -- Use Vbscript to obtain the first letter of each Chinese Character

Source: Internet
Author: User
Tags powerdesigner

Use Vbscript to obtain the first letter of each Chinese character. The script is as follows:

'The current model dim mdlset MDL = activemodelif (MDL is nothing) thenmsgbox 'does not have an activity model! "Elselistobjects (MDL) end if 'lists all objects. Private sub listobjects (e) Output" entity name: "& E. codedim objfor each OBJ in E. when the childrentablesetnametocode (OBJ) Next 'package exists, the entity object dim ffor each F in E in the recursive package. packageslistobjects fnextend sub 'conversion process private sub tablesetnametocode (currentobject) ': If not currentobject is executed when the object is an object. iskindof (cls_entity) Then exit sub 'skips if not currentobject when the object is in a shortcut. isshortcut thenoutput currentobj Ect. Name 't_is the header, which can be modified as needed. 'Call the getpy subfunction to convert the object name currentobject. code = "T _" & getpy (currentobject. name) dim Col 'running columndim index1index1 = 0' convert the attribute name in each object for each Col in currentobject. attributesdim s 'calls the getpy sub-function to complete the conversion of attribute names. S = getpy (Col. name) Col. code = snextend ifend sub 'generates the first letter of the Chinese string function getpy (strxx) dim idim getpy1for I = 1 to Len (strxx) getpy1 = getpy1 & getpychar (mid (strxx, I, 1) nextgetpy = getpy1end function 'gets the first letter of a Chinese Word. Function getpychar (char) the 'asc function returns the ANSI character code corresponding to the first letter of the string'. digits, letters, and underscores are not converted. If (ASC (char)> = ASC ("0") and ASC (char) <= ASC ("9") or (ASC (char)> = ASC ("A") and ASC (char) <= ASC ("Z") or (ASC (char)> = ASC ("A") and ASC (char) <= ASC ("Z ")) or ASC (char) = ASC ("_") then' note: in actual script execution, then must be in the same line as if getpychar = charelsedim tmpp: tmpp = 65536 + ASC (char) if (tmpp> = 45217 and tmpp <= 45252) thengetpychar = "A" elseif (tmpp> = 45253 and tmpp <= 45760) thengetpychar = "B" elseif (tmpp> = 45761 and tmpp <= 46317) thengetpychar = "C" elseif (tmpp> = 46318 and tmpp <= 46825) thengetpychar = "D" elseif (tmpp> = 46826 and tmpp <= 47009) thengetpychar = "E" elseif (tmpp> = 47010 and tmpp <= 47296) thengetpychar = "F" elseif (tmpp> = 47297 and tmpp <= 47613) thengetpychar = "G" elseif (tmpp> = 47614 and tmpp <= 48118) thengetpychar = "H" elseif (tmpp> = 48119 and tmpp <= 49061) thengetpychar = "J" elseif (tmpp> = 49062 and tmpp <= 49323) thengetpychar = "K" elseif (tmpp> = 49324 and tmpp <= 49895) thengetpychar = "L" elseif (tmpp> = 49896 and tmpp <= 50370) thengetpychar = "M" elseif (tmpp> = 50371 and tmpp <= 50613) thengetpychar = "N" elseif (tmpp> = 50614 and tmpp <= 50621) thengetpychar = "O" elseif (tmpp> = 50622 and tmpp <= 50905) thengetpychar = "p" elseif (tmpp> = 50906 and tmpp <= 51386) thengetpychar = "Q" elseif (tmpp> = 51387 and tmpp <= 51445) thengetpychar = "R" elseif (tmpp> = 51446 and tmpp <= 52217) thengetpychar = "S" elseif (tmpp> = 52218 and tmpp <= 52697) thengetpychar = "T" elseif (tmpp> = 52698 and tmpp <= 52979) thengetpychar = "W" elseif (tmpp> = 52980 and tmpp <= 53688) thengetpychar = "X" elseif (tmpp> = 53689 and tmpp <= 54480) thengetpychar = "Y" elseif (tmpp> = 54481 and tmpp <= 62289) thengetpychar = "Z" elsegetpychar = "" End ifend Function

Related Article

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.