Chapter 9 Generation Reference Guide (GTL)
The .replace macro replaces all occurrences of a string with another string in a text block.
This macro is particularly useful when you work with naming conventions.
For more information about naming conventions, see "Defining naming conventions" in the "Managing Models" chapter in the General Features Guide.
The .replace macro replaces the old string <OldString> with the <NewString> string in the text block <Block>.
.replace '(' <old-string> ',' <new-string> ')' <replace-block-input> .endreplace
Parameter | Type | Description |
---|---|---|
<old-string> | Text | String containing the character to be replaced by <new-string> |
<new-string> | Text | String containing the character replacing <old-string> |
<replace-block-input> | Complex template | Parameter used to input text |
The output is that all instances of the string <old-string> are replaced by instances of the string <new-string> in the replace block input.
In the following example, 'GetCustomerName' is converted to 'SetCustomerName'.
.replace( get , set ) GetCustomerName .endreplace
In the following example, the variable %Name% is 'Customer Factory' and it is converted to 'Customer_Factory'.
.replace(" ", "_") %Name% .endreplace
Copyright (C) 2005. Sybase Inc. All rights reserved. |