Chapter 6 Managing Models


.foreach_part macro

The .foreach_part macro allows an iteration on each part of an expression. The part separators will be specified into a pattern expression.

This macro is very useful when dealing with inter-model generation, as models can have very different naming conventions. For example a Java class attribute code may be "customerName" whereas a PDM table column code may be "CUSTOMER_NAME".

Syntax

. foreach_part (<Expression> [, <Separator Pattern>[,<Head> [, <Tail>]]])
[<Block>]
.next[(<Separator>)]

Parameters

Parameter Description
<Expression> Designates the expression scanned by the part iterator. This part iterator will stop on each character specified into the <PartSeparatorPattern>
<Separator Pattern> (optional) Defined into a double quoted string. Any character specified into the pattern will be used as a part separator.

See below
<Block> Encompasses the following variables:

%CurrentPart%: Current part value,

%IsFirst%: Determines if the current part is the first part of the expression,

%IsLast%: Determines if the current part is the last part of the expression
<Separator> (optional) A <separator> can be concatenated between each part. If you defined a character separator in the <PartSeparatorPattern>, the value of the <separator> will replace the character separator. If you defined a range separator in the <PartSeparatorPattern>, the table conversion you selected will return the corresponding value to replace the range separator
<Head> or <Tail> (optional) Expressions that can be added respectively at the beginning or at the end of the generated expression

Separator

There are two types of separator:

Both can also be combined: (%Name,"'<char>',[<c1>-<c2>]"). '<char>' can be any character specified into the pattern for example: a, b , c, 0, 9.

[<c1> - <c2>] specifies a character taken into the range defined between the two characters <c1> and <c2>. For example, [A-Z], [a-z] or [0-9]" can be used as part separators.

By default, the <PartSeparatorPattern> is initialized by the pattern " -_,\t". If the specified pattern is empty the pattern is initialized using the default value.

Examples

 


Copyright (C) 2005. Sybase Inc. All rights reserved.