Name and Code Conversion Scripts

Conversion scripts permit more complex transformations, including adding prefixes or suffixes and the use of conversion tables. You specify the script on the Name to Code or Code to Name tab, depending on which direction you want to perform the conversion.

Note: To enable the use of your conversion script, you must select Enable name/code conversions in the upper part of the Naming Convention page of the Model Options dialog.


The following options are available on each of these tabs:

Option

Description

Conversion script

The default Name to Code conversion script is:
.convert_name(%Name%,"_")
This script takes the value of the Name field (represented by the GTL variable %Name%) and generates a Code by replacing any nonalphanumeric characters with an underscore.

It also calls a conversion table (if one is selected in the Conversion table field) to perform conversions on specific strings encountered in the name or code.

You can modify the conversion script. For example, to insert the prefix tbl_ before the code of each table, use:
.convert_name(tbl_%Name%,"_")
If the stdnames conversion table is selected then, for a table with the name Customer, PowerDesigner automatically provides a code tbl_CUST.

You can enter any valid GTL code (including macros such as .foreach_part, .lowercase, .uppercase, .replace, and .delete), but only the .convert_name and .convert_code macros call a conversion table if one is selected.

For detailed information about GTL, see Customizing and Extending PowerDesigner > Customizing Generation with GTL .

Conversion table

Specifies the conversion table to use to perform conversions on specific strings encountered in the name or code (see Creating a Conversion Table).

PowerDesigner provides an example conversion table called stdnames.csv. For example, an object name Customer_1 is transformed into the object code CUST_1 if stdnames is selected.

To use your glossary term names and codes (see The Library) as a conversion table, select glossary terms.

Apply name to code conversion/ Apply code to name conversion to all objects

Applies the conversion script (and conversion table) when you click OK:
  • To synchronized objects - those objects in which the object code is currently synchronized with the name.
  • To all objects - all objects in the model regardless of whether the object code is synchronized with the name.

The option on the Code to Name tab always applies your changes to all objects in the model.

Note: When generating one model from another, you can use name to code conversion to provide appropriate codes for the target model objects (see the Convert Names into Codes options on the Model Generation Options Window Detail Tab).