For parsing and composing flat files there is a set of counters and related macros available that provide extended features.
Type | Parse | Compose | Description | ID |
---|---|---|---|---|
automatic counters | Eight automatic counters that can be accessed via their IDs AUTO0 .. AUTO7 . | AUTO0 .. AUTO7 | ||
automatic line counters | Two automatic line counters that can be accessed via their IDs LINE0 and LINE1 . | LINE0 , LINE1 | ||
custom counters | Unlimited custom counters that can be accessed via their IDs CUSTOM0 .. CUSTOMx . | CUSTOM0 .. CUSTOMx |
You cannot access these counters directly but only via the macro expressions listed in the table below. Macro expressions referring to one of the counters can be specified on flat file records and on flat file properties (see also Defining a Flat File Data Structure) in the stereotype attributes parseMacro and composeMAcro.
The counters can be handled using the following macros:
Macro | Available on | Available for | Description | Example |
---|---|---|---|---|
ResetCounter( | Record Property |
| Reset the counter | ResetCounter(AUTO0) ResetCounter(AUTO0, 1) |
IncreaseCounter( | Record Property | AUTO | Increases the counter | IncreaseCounter(CUSTOM2) |
GetCounter( | Property | AUTO | Read the value of a counter and store it to the current attribute. | GetCounter(LINE0) |
VerifyCounter( | Property | AUTO | Compare the value of a counter with the current attribute. This macro will throw an exception if the values are not equal. | VerifyCounter(CUSTOM0) |
For GetCounter() and VerifyCounter() only attributes of type Integer are supported. |
The Flat File adapter example shows the usage of an automatic counter to provide a line number to the data records during the composing process. Refer to Defining a Flat File Data Structure for more details on the example flat file.
GetCounter(AUTO0)
.ResetCounter(AUTO0)
. This way the header record will not be counted.The picture below shows the composing process for the example with emphasis on macro execution.