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 the Enable name/code conversions check box 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 non alpha-numeric 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 as necessary. For example, to insert the prefix tbl_ before the code of each table, use the following script:
.convert_name(tbl_%Name%,"_")
If the stdnames conversion table is selected then, for a table with the name Customer, PowerDesigner will automatically provide 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 will call a conversion table if one is selected.

For detailed information about GTL, see Chapter 4, Customizing Generation with GTL in Customizing and Extending PowerDesigner .

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 would be transformed into the object code CUST_1 if stdnames was selected.

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 presently synchronized with the name.
  • To all objects - all objects in the model regardless of whether the object name is currently synchronized with the name.

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

Note:

When generating one model from another, name to code conversion can be used to provide appropriate codes for the target model objects. For more information, see the Convert Names into Codes options on the Model Generation Options Window Detail Tab).