COUNTER defines a special kind of inline variable. When used in the input files, the value of the inline variable is adapted after replacement depending on the type, incremental value (see COUNTERINCR) and the action (see Inline Variable), 



Counter defined as a variable

The primary use of counter is to define the name of the start value and its initial value. When used as an inline variable in the input file (@ followed by the name of the counter), the current value of the counter is included, and the value is changed by an incremental value (default is adding a value of 1, the value can be redefined by COUNTERINCR, the operand by the symbol following @ (Inline Variable)).

COUNTER also resets the value back to its start value when the name starts with &.

Optionally, the end value of a counter can be defined as well. This value can be used to create plots when selected_graph is used.



Counter linked to a datablock or to a file

When counter is followed with datablock or file, the counter is linked to either a datablock or a file containing a table. The counter is an integer corresponding to the row in the datablock, or the row in the table. After replacement, the counter is increased by a value of 1, but by using an equal sign, the counter remains the same. The counter can be reset to the starting value (Default: 0 if a start_value is not defined) as well. 

The inline variable (@) refers to the name of the counter and the column heading name as:


       @<:txt:Counter Name>:<:txt:Column Heading Name> 


where both Counter Name and Column Heading Name are case sensitive.


For the datablock option, the corresponding datablock can be defined further in the input file. However, when the inline variable is used in the input file, both the counter and the datablock should be defined. Note that the counter should have the same name as the datablock.


For the file option, the corresponding file can be generated at later times during the execution. However, when the inline variable is used in the input file, both the counter should be defined and the file should be present. The file name can be a full path, a file in or relative to the simulation directory or in or relative to any other path defined by INCLUDEPATH.  The first line of the file contains the (case-sensitive) headings of the different columns in the table, the next lines contains the values. The file can be space, tab, comma or semi-colon separated (or any mixture of these delimiters). The first time the inline variable refers to the counter, the file is read by the program and interpreted as a datablock.


The inline variable can also retrieve the number of records by using :nrrec: instead of the Column Heading Name:


       @<:txt:Counter Name>:nrrec


In that case, the counter keeps its actual value (no increment by the value of 1).


Definition


#Define a counter by a variable name - it can be linked to a COUNTERINCR statement to define the incremental value.

counteR <:txt:name> <flt:start_value> [<flt:end_value>]

counteR <:txt:name> = <exp:start_value_exp> 

counteR &<:txt:name> 


#Define a counter linked to a datablock or to a file

counter datablock <:txt:datablock name> [<int:start_value>]

COUNTER file <txt:file name> <:str:file>         [<int:start_value>]



Explanation


name

txt

Name of the counter (inline variable).

When the counter is not defined yet, it is initialized with a start value of 1 and an incremental value of 1.

When the name is followed by an equal sign "=", an inline expression is used to calculate the start value.

When the name is preceded with the & symbol, the actual value of the inline variable is reset to its previously defined start value.

start_value

flt

Start value of the counter. 

end_value

flt

(optional) End value of the counter. The end value can only be defined when the equal sign is not used. The end value does not have any effect on the behaviour of the counter. It is only used to link output blocks to counter values in selected_graph.

start_value_exp

exp

Inline expression for calculating the start value - see "Definition of inline variables" and "Examples of inline definition and use"




File Name

txt

the name of the counter. When a name is defined for the file case, the name cannot be in use as a previously defined counter based on file or as a name for a datablock.